|
13 | 13 | from pendulum.tz import fixed_timezone |
14 | 14 | from pendulum.tz.exceptions import AmbiguousTime |
15 | 15 | from pendulum.tz.exceptions import NonExistingTime |
| 16 | +from pendulum.tz.timezone import FixedTimezone |
16 | 17 | from tests.conftest import assert_datetime |
17 | 18 |
|
18 | 19 |
|
@@ -47,6 +48,11 @@ def test_equality(): |
47 | 48 | assert timezone("Europe/Paris") != timezone("Europe/Berlin") |
48 | 49 |
|
49 | 50 |
|
| 51 | +def test_hash(): |
| 52 | + assert hash(timezone("Europe/Paris")) == hash(timezone("Europe/Paris")) |
| 53 | + assert len({timezone("Europe/Paris"), timezone("Europe/Paris")}) == 1 |
| 54 | + |
| 55 | + |
50 | 56 | def test_skipped_time_with_pre_rule(): |
51 | 57 | dt = datetime(2013, 3, 31, 2, 30, 45, 123456, fold=0) |
52 | 58 | tz = timezone("Europe/Paris") |
@@ -409,6 +415,14 @@ def test_fixed_equality(): |
409 | 415 | assert fixed_timezone(19800) != fixed_timezone(19801) |
410 | 416 |
|
411 | 417 |
|
| 418 | +def test_fixed_hash(): |
| 419 | + assert hash(fixed_timezone(19800)) == hash(fixed_timezone(19800)) |
| 420 | + assert fixed_timezone(19800) == FixedTimezone(19800, name="custom"), ( |
| 421 | + "Pre-condition: name ignored for FixedTimezone" |
| 422 | + ) |
| 423 | + assert len({fixed_timezone(19800), FixedTimezone(19800, name="custom")}) == 1 |
| 424 | + |
| 425 | + |
412 | 426 | def test_just_before_last_transition(): |
413 | 427 | tz = pendulum.timezone("Asia/Shanghai") |
414 | 428 | dt = datetime(1991, 4, 20, 1, 49, 8, fold=0) |
|
0 commit comments