docker-py
docker-py copied to clipboard
tests: Fix deprecation warning for utcfromtimestamp()
Fix DeprecationWarning for datetime.datetime.utcfromtimestamp()
It suggests to use timezone-aware objects to represent datetimes in UTC with datetime.UTC but datetime.timezone.utc is backwards compatible.
Verification run: https://openqa.opensuse.org/tests/5261910#downloads
tests/unit/api_container_test.py::ContainerTest::test_log_since_with_datetime
/src/tests/unit/api_container_test.py:1305: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
time = datetime.datetime.utcfromtimestamp(ts)
tests/unit/api_test.py::DockerApiTest::test_events_with_since_until
/src/tests/unit/api_test.py:234: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
now = datetime.datetime.utcfromtimestamp(ts)
Fixes deprecation warning noticed in https://github.com/docker/docker-py/issues/3335
cc @thaJeztah