Skip to content

Commit

Permalink
Use timezone.utc instead of UTC alias in tests for backward compatibi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
m0rl committed Feb 10, 2024
1 parent 4ef2ef2 commit 0820ab5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/test_evaluators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, UTC
from datetime import datetime, timezone
from unittest import mock
from decimal import Decimal
import pytest
Expand Down Expand Up @@ -222,16 +222,16 @@ def misc_functions_test(resource, path, expected):
def datetime_json_serialization_test(expression: str, expected_json: str):
with mock.patch("fhirpathpy.engine.invocations.datetime.datetime") as datetime_mock:
datetime_mock.now.return_value = datetime(
2020, 8, 20, 17, 52, 15, 123000, tzinfo=UTC
2020, 8, 20, 17, 52, 15, 123000, tzinfo=timezone.utc
)
assert json.dumps(evaluate({}, expression)) == expected_json


def now_function_test():
with mock.patch("fhirpathpy.engine.invocations.datetime.datetime") as datetime_mock:
datetime_mock.now.side_effect = [
datetime(2020, 8, 20, 17, 52, 15, 123000, tzinfo=UTC),
datetime(2020, 8, 20, 17, 52, 16, 123000, tzinfo=UTC),
datetime(2020, 8, 20, 17, 52, 15, 123000, tzinfo=timezone.utc),
datetime(2020, 8, 20, 17, 52, 16, 123000, tzinfo=timezone.utc),
]
old_now_value = evaluate({}, "now()")
new_now_value = evaluate({}, "now()")
Expand Down

0 comments on commit 0820ab5

Please sign in to comment.