Skip to content

Commit df1ff91

Browse files
committed
Fixes test
1 parent 004e561 commit df1ff91

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

pendulum/pendulum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ def is_birthday(self, dt=None):
14081408
:rtype: bool
14091409
"""
14101410
if dt is None:
1411-
dt = Pendulum.now(self.timezone)
1411+
dt = Pendulum.now(self._tz)
14121412

14131413
instance = self._get_datetime(dt, True)
14141414

tests/pendulum_tests/test_comparison.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,14 @@ def test_max_with_instance(self):
330330
self.assertPendulum(d2, 2099, 12, 31, 23, 59, 59)
331331

332332
def test_is_birthday(self):
333-
d = Pendulum.now()
334-
a_birthday = d.subtract(years=1)
335-
print(d, a_birthday)
336-
self.assertTrue(a_birthday.is_birthday())
337-
not_a_birthday = d.subtract(days=1)
338-
self.assertFalse(not_a_birthday.is_birthday())
339-
also_not_a_birthday = d.add(days=2)
340-
self.assertFalse(also_not_a_birthday.is_birthday())
333+
with self.wrap_with_test_now():
334+
d = Pendulum.now()
335+
a_birthday = d.subtract(years=1)
336+
self.assertTrue(a_birthday.is_birthday())
337+
not_a_birthday = d.subtract(days=1)
338+
self.assertFalse(not_a_birthday.is_birthday())
339+
also_not_a_birthday = d.add(days=2)
340+
self.assertFalse(also_not_a_birthday.is_birthday())
341341

342342
d1 = Pendulum(1987, 4, 23)
343343
d2 = Pendulum(2014, 9, 26)

tests/pendulum_tests/test_getters.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,25 @@ def test_is_weekend(self):
164164
self.assertTrue(d.is_weekend())
165165

166166
def test_is_today(self):
167-
d = Pendulum.now()
168-
self.assertTrue(d.is_today())
169-
d = d.subtract(days=1)
170-
self.assertFalse(d.is_today())
167+
with self.wrap_with_test_now():
168+
d = Pendulum.now()
169+
self.assertTrue(d.is_today())
170+
d = d.subtract(days=1)
171+
self.assertFalse(d.is_today())
171172

172173
def test_is_yesterday(self):
173-
d = Pendulum.now()
174-
print(d, d.tomorrow(d.timezone))
175-
self.assertFalse(d.is_yesterday())
176-
d = d.subtract(days=1)
177-
self.assertTrue(d.is_yesterday())
174+
with self.wrap_with_test_now():
175+
d = Pendulum.now()
176+
self.assertFalse(d.is_yesterday())
177+
d = d.subtract(days=1)
178+
self.assertTrue(d.is_yesterday())
178179

179180
def test_is_tomorrow(self):
180-
d = Pendulum.now()
181-
self.assertFalse(d.is_tomorrow())
182-
d = d.add(days=1)
183-
self.assertTrue(d.is_tomorrow())
181+
with self.wrap_with_test_now():
182+
d = Pendulum.now()
183+
self.assertFalse(d.is_tomorrow())
184+
d = d.add(days=1)
185+
self.assertTrue(d.is_tomorrow())
184186

185187
def test_is_future(self):
186188
with self.wrap_with_test_now():

0 commit comments

Comments
 (0)