@@ -254,21 +254,15 @@ def test_is_anniversary():
254254 assert d3 .is_anniversary (d1 )
255255
256256
257- def test_is_birthday (): # backward compatibility
258- with pendulum .test (pendulum .now ()):
259- d = pendulum .now ()
260- an_anniversary = d .subtract (years = 1 )
261- assert an_anniversary .is_birthday ()
262- not_an_anniversary = d .subtract (days = 1 )
263- assert not not_an_anniversary .is_birthday ()
264- also_not_an_anniversary = d .add (days = 2 )
265- assert not also_not_an_anniversary .is_birthday ()
266-
267- d1 = pendulum .datetime (1987 , 4 , 23 )
268- d2 = pendulum .datetime (2014 , 9 , 26 )
269- d3 = pendulum .datetime (2014 , 4 , 23 )
270- assert not d2 .is_birthday (d1 )
271- assert d3 .is_birthday (d1 )
257+ def test_next_anniversary ():
258+ start = pendulum .datetime (1987 , 6 , 23 )
259+ leap_start = pendulum .datetime (1988 , 2 , 29 )
260+
261+ assert start .next_anniversary () == pendulum .datetime (2020 , 6 , 23 )
262+ assert leap_start .next_anniversary () == pendulum .datetime (2021 , 2 , 28 )
263+ next_year = pendulum .datetime (2021 , 1 , 1 )
264+ assert start .next_anniversary (dt = next_year ) == pendulum .datetime (2021 , 6 , 23 )
265+ assert leap_start .next_anniversary (dt = next_year ) == pendulum .datetime (2021 , 2 , 28 )
272266
273267
274268def test_closest ():
0 commit comments