tests/tz/test_timezone.py::test_dst, tests/datetime/test_behavior.py::test_proper_dst tests fail
-
[x] I am on the latest Pendulum version.
-
[x] I have searched the issues of this repo and believe that this is not a duplicate.
-
OS version and name: Gentoo Linux amd64
-
Pendulum version: 2.1.2 + git ca589aaa85f9e9113e49d5ef37305715f7d44295
Issue
On my system, the two following tests fail:
$ poetry run pytest tests
========================================================= test session starts =========================================================
platform linux -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0
rootdir: /tmp/pendulum
plugins: time-machine-2.7.1, cov-3.0.0
collected 1724 items
tests/test_helpers.py .................... [ 1%]
tests/test_main.py . [ 1%]
tests/test_parsing.py ....... [ 1%]
tests/date/test_add.py ................ [ 2%]
tests/date/test_behavior.py ........... [ 3%]
tests/date/test_comparison.py ......................... [ 4%]
tests/date/test_construct.py .. [ 4%]
tests/date/test_day_of_week_modifiers.py ..................................................... [ 7%]
tests/date/test_diff.py .................................................................... [ 11%]
tests/date/test_fluent_setters.py ... [ 11%]
tests/date/test_getters.py .............. [ 12%]
tests/date/test_start_end_of.py ......................................... [ 15%]
tests/date/test_strings.py ........ [ 15%]
tests/date/test_sub.py ................ [ 16%]
tests/datetime/test_add.py ................................ [ 18%]
tests/datetime/test_behavior.py ......................F.. [ 19%]
tests/datetime/test_comparison.py .................................... [ 21%]
tests/datetime/test_construct.py .................... [ 23%]
tests/datetime/test_create_from_timestamp.py ... [ 23%]
tests/datetime/test_day_of_week_modifiers.py ....................................................... [ 26%]
tests/datetime/test_diff.py ................................................................................................... [ 32%]
............................... [ 33%]
tests/datetime/test_fluent_setters.py .................. [ 35%]
tests/datetime/test_from_format.py ............................................................ [ 38%]
tests/datetime/test_getters.py ....................................... [ 40%]
tests/datetime/test_naive.py ......... [ 41%]
tests/datetime/test_replace.py .... [ 41%]
tests/datetime/test_start_end_of.py ............................................ [ 44%]
tests/datetime/test_strings.py ........................ [ 45%]
tests/datetime/test_sub.py ............................. [ 47%]
tests/datetime/test_timezone.py ... [ 47%]
tests/duration/test_add_sub.py ....... [ 47%]
tests/duration/test_arithmetic.py ... [ 47%]
tests/duration/test_behavior.py .. [ 48%]
tests/duration/test_construct.py ............ [ 48%]
tests/duration/test_in_methods.py ..... [ 49%]
tests/duration/test_in_words.py ........... [ 49%]
tests/duration/test_total_methods.py ..... [ 49%]
tests/formatting/test_formatter.py ..................... [ 51%]
tests/helpers/test_local_time.py .. [ 51%]
tests/localization/test_cs.py .. [ 51%]
tests/localization/test_da.py . [ 51%]
tests/localization/test_de.py . [ 51%]
tests/localization/test_es.py . [ 51%]
tests/localization/test_fa.py . [ 51%]
tests/localization/test_fo.py . [ 51%]
tests/localization/test_fr.py .. [ 51%]
tests/localization/test_he.py . [ 51%]
tests/localization/test_id.py . [ 51%]
tests/localization/test_it.py .. [ 52%]
tests/localization/test_ja.py . [ 52%]
tests/localization/test_ko.py . [ 52%]
tests/localization/test_lt.py . [ 52%]
tests/localization/test_nb.py .. [ 52%]
tests/localization/test_nl.py .. [ 52%]
tests/localization/test_nn.py .. [ 52%]
tests/localization/test_pl.py .. [ 52%]
tests/localization/test_ru.py . [ 52%]
tests/localization/test_sv.py . [ 52%]
tests/parsing/test_parse_iso8601.py ... [ 52%]
tests/parsing/test_parsing.py .................... [ 54%]
tests/parsing/test_parsing_duration.py ...... [ 54%]
tests/period/test_add_subtract.py ..... [ 54%]
tests/period/test_arithmetic.py ... [ 54%]
tests/period/test_behavior.py ... [ 55%]
tests/period/test_construct.py ........ [ 55%]
tests/period/test_hashing.py .. [ 55%]
tests/period/test_in_words.py ......... [ 56%]
tests/period/test_range.py .......... [ 56%]
tests/time/test_add.py ............ [ 57%]
tests/time/test_behavior.py ..... [ 57%]
tests/time/test_comparison.py .................... [ 58%]
tests/time/test_construct.py .. [ 59%]
tests/time/test_diff.py .................................................... [ 62%]
tests/time/test_fluent_setters.py . [ 62%]
tests/time/test_strings.py ...... [ 62%]
tests/time/test_sub.py ............. [ 63%]
tests/tz/test_helpers.py ... [ 63%]
tests/tz/test_local_timezone.py ..s. [ 63%]
tests/tz/test_timezone.py .................F..s........s. [ 65%]
tests/tz/test_timezones.py .................................................................................................... [ 71%]
............................................................................................................................... [ 78%]
............................................................................................................................... [ 85%]
............................................................................................................................... [ 93%]
................................................................................................................... [100%]
============================================================== FAILURES ===============================================================
___________________________________________________________ test_proper_dst ___________________________________________________________
def test_proper_dst():
dt = pendulum.datetime(1941, 7, 1, tz="Europe/Amsterdam")
> assert dt.dst() == timedelta(0, 6000)
E AssertionError: assert datetime.timedelta(seconds=3600) == datetime.timedelta(seconds=6000)
E + where datetime.timedelta(seconds=3600) = <built-in method dst of DateTime object at 0x7f8a0d3625c0>()
E + where <built-in method dst of DateTime object at 0x7f8a0d3625c0> = DateTime(1941, 7, 1, 0, 0, 0, tzinfo=Timezone('Europe/Amsterdam')).dst
E + and datetime.timedelta(seconds=6000) = timedelta(0, 6000)
tests/datetime/test_behavior.py:151: AssertionError
______________________________________________________________ test_dst _______________________________________________________________
def test_dst():
tz = pendulum.timezone("Europe/Amsterdam")
dst = tz.dst(datetime(1940, 7, 1))
> assert dst == timedelta(0, 6000)
E assert datetime.timedelta(seconds=3600) == datetime.timedelta(seconds=6000)
E + where datetime.timedelta(seconds=6000) = timedelta(0, 6000)
tests/tz/test_timezone.py:236: AssertionError
======================================================= short test summary info =======================================================
FAILED tests/datetime/test_behavior.py::test_proper_dst - AssertionError: assert datetime.timedelta(seconds=3600) == datetime.timede...
FAILED tests/tz/test_timezone.py::test_dst - assert datetime.timedelta(seconds=3600) == datetime.timedelta(seconds=6000)
============================================== 2 failed, 1719 passed, 3 skipped in 2.94s ==============================================
Time in Amsterdam during WW2 is complicated: https://en.wikipedia.org/wiki/Summer_time_in_Europe#Netherlands, https://www.timeanddate.com/time/zone/netherlands/amsterdam?year=1940
In 1940 the German occupants forced the Netherlands to observe CEST, Germany's Daylight Saving Time, effectively advancing its time by one hour and 40 minutes. This time stayed in effect year round until 1942, when the normal clock followed the German DST switches.
Whether the 6000 seconds advancement are to be construed as DST, or the real DST is the 1h difference to Nazi-German CET, apparently changed in the underlying datetime implementation.