mirror of
https://github.com/craigerl/aprsd.git
synced 2026-09-08 04:25:31 -04:00
fix: replace deprecated datetime.utcfromtimestamp()/utcnow() calls (#268)
Both APIs are deprecated since Python 3.12 and scheduled for removal.
- aprsd/packets/core.py: datetime.utcfromtimestamp(ts)
-> datetime.fromtimestamp(ts, tz=timezone.utc)
- aprsd/plugins/time.py: pytz.datetime.datetime.utcnow()
-> datetime.now(timezone.utc).replace(tzinfo=None)
(naive UTC returned to preserve pytz.utc.localize() contract)
- tests/plugins/test_time.py: same fix in test setup
Closes #249
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import datetime as _dt
|
||||
from unittest import mock
|
||||
|
||||
import pytz
|
||||
@@ -15,7 +16,7 @@ class TestTimePlugins(test_plugin.TestPlugin):
|
||||
@mock.patch('aprsd.plugins.time.TimePlugin._get_local_tz')
|
||||
@mock.patch('aprsd.plugins.time.TimePlugin._get_utcnow')
|
||||
def test_time(self, mock_utcnow, mock_localtz):
|
||||
utcnow = pytz.datetime.datetime.utcnow()
|
||||
utcnow = _dt.datetime.now(_dt.timezone.utc).replace(tzinfo=None)
|
||||
mock_utcnow.return_value = utcnow
|
||||
tz = pytz.timezone('US/Pacific')
|
||||
mock_localtz.return_value = tz
|
||||
|
||||
Reference in New Issue
Block a user