Browse Source

_timestamp_to_utc_dt: replace dateutil.tz with dt.timezone; move assertion to tests/test_functions.py

Fabian Peter Hammerle 5 years ago
parent
commit
b658ee6156
2 changed files with 12 additions and 5 deletions
  1. 1 5
      symuid/__init__.py
  2. 11 0
      tests/test_functions.py

+ 1 - 5
symuid/__init__.py

@@ -1,7 +1,6 @@
 # -*- coding: utf-8 -*-
 
 import datetime as dt
-import dateutil.tz
 import mutagen
 import os
 import re
@@ -11,10 +10,7 @@ import symuid.tag_interface
 
 def _timestamp_to_utc_dt(ts):
     return dt.datetime.utcfromtimestamp(ts) \
-        .replace(tzinfo=dateutil.tz.tzutc())
-
-assert _timestamp_to_utc_dt(1528795204) \
-    == dt.datetime(2018, 6, 12, 9, 20, 4, tzinfo=dateutil.tz.tzutc())
+        .replace(tzinfo=dt.timezone.utc)
 
 
 class PlayCount:

+ 11 - 0
tests/test_functions.py

@@ -0,0 +1,11 @@
+import pytest
+
+import symuid
+
+import datetime as dt
+
+@pytest.mark.parametrize(('ts', 'expected_dt'), [
+    (1528795204, dt.datetime(2018, 6, 12, 9, 20, 4, tzinfo=dt.timezone.utc)),
+])
+def test__timestamp_to_utc_dt(ts, expected_dt):
+    assert expected_dt == symuid._timestamp_to_utc_dt(ts)