Skip to content

Commit 439c15f

Browse files
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. Signed-off-by: Ricardo Branco <rbranco@suse.de>
1 parent 6e6a273 commit 439c15f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tests/unit/api_container_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ def test_log_since_with_float(self):
13021302

13031303
def test_log_since_with_datetime(self):
13041304
ts = 809222400
1305-
time = datetime.datetime.utcfromtimestamp(ts)
1305+
time = datetime.datetime.fromtimestamp(ts, datetime.timezone.utc)
13061306
with mock.patch('docker.api.client.APIClient.inspect_container',
13071307
fake_inspect_container):
13081308
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False,

tests/unit/api_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def test_events(self):
232232
def test_events_with_since_until(self):
233233
ts = 1356048000
234234
now = datetime.datetime.utcfromtimestamp(ts)
235+
now = datetime.datetime.fromtimestamp(ts, datetime.timezone.utc)
235236
since = now - datetime.timedelta(seconds=10)
236237
until = now + datetime.timedelta(seconds=10)
237238

0 commit comments

Comments
 (0)