diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-02-09 23:50:47 +0200 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-02-10 00:04:14 +0200 |
commit | 20808b11414c5d7621c88b394196c82770a7e3d4 (patch) | |
tree | ca92c25f4030f080af2234aec4cf0997e54ab0c2 | |
parent | 13420163f1ebcd6253f4134660c44d5f1b0fc312 (diff) | |
download | apscheduler-20808b11414c5d7621c88b394196c82770a7e3d4.tar.gz |
Use the standard tzinfo tzname() method instead of the pytz attribute
This avoids one of the deprecation warnings.
-rw-r--r-- | apscheduler/util.py | 2 | ||||
-rw-r--r-- | tests/test_util.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/apscheduler/util.py b/apscheduler/util.py index 1e643bf..196b81d 100644 --- a/apscheduler/util.py +++ b/apscheduler/util.py @@ -92,7 +92,7 @@ def astimezone(obj): if isinstance(obj, tzinfo): if not hasattr(obj, 'localize') or not hasattr(obj, 'normalize'): raise TypeError('Only timezones from the pytz library are supported') - if obj.zone == 'local': + if obj.tzname(None) == 'local': raise ValueError( 'Unable to determine the name of the local timezone -- you must explicitly ' 'specify the name of the local timezone. Please refrain from using timezones like ' diff --git a/tests/test_util.py b/tests/test_util.py index 7cadbc2..ab10f50 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -98,7 +98,7 @@ class TestAstimezone(object): assert 'Only timezones from the pytz library are supported' in str(exc.value) def test_bad_local_timezone(self): - zone = Mock(tzinfo, localize=None, normalize=None, zone='local') + zone = Mock(tzinfo, localize=None, normalize=None, tzname=lambda dt: 'local') exc = pytest.raises(ValueError, astimezone, zone) assert 'Unable to determine the name of the local timezone' in str(exc.value) |