Skip to content

Commit

Permalink
fix attime tests for python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
deniszh committed Aug 25, 2024
1 parent 5dbf595 commit 9a98794
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions webapp/tests/test_attime.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ def test_should_handle_dst_boundary(self):
def test_parse_naive_datetime(self):
time_ref = parseATTime(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50), self.specified_tz)
expected = self.specified_tz.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)

def test_parse_zone_aware_datetime(self):
time_ref = parseATTime(self.specified_tz.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50)), self.specified_tz)
expected = self.specified_tz.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)


@mock.patch('graphite.render.attime.datetime', mockDateTime(2015, 1, 1, 11, 0, 0))
Expand All @@ -118,19 +118,19 @@ class parseTimeReferenceTest(TestCase):

def test_parse_empty_return_now(self):
time_ref = parseTimeReference('')
self.assertEquals(time_ref, self.MOCK_DATE)
self.assertEqual(time_ref, self.MOCK_DATE)

def test_parse_None_return_now(self):
time_ref = parseTimeReference(None)
self.assertEquals(time_ref, self.MOCK_DATE)
self.assertEqual(time_ref, self.MOCK_DATE)

def test_parse_random_string_raise_Exception(self):
with self.assertRaises(Exception):
parseTimeReference("random")

def test_parse_now_return_now(self):
time_ref = parseTimeReference("now")
self.assertEquals(time_ref, self.MOCK_DATE)
self.assertEqual(time_ref, self.MOCK_DATE)

def test_parse_colon_raises_ValueError(self):
with self.assertRaises(ValueError):
Expand All @@ -139,32 +139,32 @@ def test_parse_colon_raises_ValueError(self):
def test_parse_naive_datetime(self):
time_ref = parseTimeReference(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50))
expected = self.zone.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)

def test_parse_zone_aware_datetime(self):
time_ref = parseTimeReference(self.zone.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50)))
expected = self.zone.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)

def test_parse_hour_return_hour_of_today(self):
time_ref = parseTimeReference("8:50")
expected = self.zone.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)

def test_parse_hour_am(self):
time_ref = parseTimeReference("8:50am")
expected = self.zone.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 50))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)

def test_parse_hour_pm(self):
time_ref = parseTimeReference("8:50pm")
expected = self.zone.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 20, 50))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)

def test_parse_hour_only_am(self):
time_ref = parseTimeReference("8am")
expected = self.zone.localize(datetime(self.MOCK_DATE.year, self.MOCK_DATE.month, self.MOCK_DATE.day, 8, 0))
self.assertEquals(time_ref, expected)
self.assertEqual(time_ref, expected)

def test_parse_hour_only_pm(self):
time_ref = parseTimeReference("10pm")
Expand Down

0 comments on commit 9a98794

Please sign in to comment.