Skip to content

Commit

Permalink
Fix timezone in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Onager committed Jul 17, 2024
1 parent 8df52bf commit 3221e06
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/lib/validators/datetime_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def testInit(self):

def testValidateSuccess(self):
"""Tests a successful validation."""
date_value = datetime.datetime(2023, 12, 31, 23, 29, 59)
date_value = datetime.datetime(
2023, 12, 31, 23, 29, 59, tzinfo=datetime.timezone.utc)
date_string = '2023-12-31 23:29:59'
val = self.validator.Validate(date_string, self.recipe_argument)
self.assertEqual(val, date_value)
Expand All @@ -35,7 +36,8 @@ def testValidateSuccessWithOrder(self):
first_string = '2023-01-01 00:00:00'
second_string = '2023-01-02 00:00:00'
third_string = '2023-01-03 00:00:00'
third_datetime = datetime.datetime(2023, 1, 3, 0, 0, 0, tzinfo=datetime.UTC)
third_datetime = datetime.datetime(
2023, 1, 3, 0, 0, 0, tzinfo=datetime.timezone.utc)
fourth_string = '2023-01-04 00:00:00'
fifth_string = '2023-01-05 00:00:00'

Expand Down Expand Up @@ -92,12 +94,12 @@ def testValidate(self):
timeless_string = '20240101'
val = self.validator.Validate(timeless_string, self.recipe_argument)
self.assertEqual(val, datetime.datetime(
2024, 1, 1, 23, 59, 59, tzinfo=datetime.UTC))
2024, 1, 1, 23, 59, 59, tzinfo=datetime.timezone.utc))

string_with_time = '2024-01-01 09:13:00'
val = self.validator.Validate(string_with_time, self.recipe_argument)
self.assertEqual(val, datetime.datetime(
2024, 1, 1, 9, 13, 0, tzinfo=datetime.UTC))
2024, 1, 1, 9, 13, 0, tzinfo=datetime.timezone.utc))

if __name__ == '__main__':
unittest.main()

0 comments on commit 3221e06

Please sign in to comment.