|
10 | 10 | from ..conftest import assert_datetime |
11 | 11 |
|
12 | 12 |
|
| 13 | +@pytest.fixture(autouse=True) |
| 14 | +def setup(): |
| 15 | + pendulum.tz._tz_cache = {} |
| 16 | + |
| 17 | + yield |
| 18 | + |
| 19 | + pendulum.tz._tz_cache = {} |
| 20 | + |
| 21 | + |
13 | 22 | @pytest.mark.skipif(not PY36, reason='fold attribute only present in Python 3.6+') |
14 | 23 | def test_basic_convert(): |
15 | 24 | dt = datetime(2016, 6, 1, 12, 34, 56, 123456, fold=1) |
@@ -497,6 +506,48 @@ def test_timezones_are_extended(): |
497 | 506 | assert dt.dst() == timedelta() |
498 | 507 |
|
499 | 508 |
|
| 509 | +def test_timezones_extension_can_be_disabled(): |
| 510 | + tz = pendulum.timezone('Europe/Paris', extended=False) |
| 511 | + dt = tz.convert(pendulum.naive(2134, 2, 13, 1)) |
| 512 | + |
| 513 | + assert_datetime(dt, 2134, 2, 13, 1) |
| 514 | + assert dt.utcoffset().total_seconds() == 3600 |
| 515 | + assert dt.dst() == timedelta() |
| 516 | + |
| 517 | + dt = tz.convert( |
| 518 | + pendulum.naive(2134, 3, 28, 2, 30), |
| 519 | + dst_rule=pendulum.POST_TRANSITION |
| 520 | + ) |
| 521 | + |
| 522 | + assert_datetime(dt, 2134, 3, 28, 2, 30) |
| 523 | + assert dt.utcoffset().total_seconds() == 3600 |
| 524 | + assert dt.dst() == timedelta() |
| 525 | + |
| 526 | + dt = tz.convert(pendulum.naive(2134, 7, 11, 2, 30)) |
| 527 | + |
| 528 | + assert_datetime(dt, 2134, 7, 11, 2, 30) |
| 529 | + assert dt.utcoffset().total_seconds() == 3600 |
| 530 | + assert dt.dst() == timedelta() |
| 531 | + |
| 532 | + dt = tz.convert( |
| 533 | + pendulum.naive(2134, 10, 31, 2, 30), |
| 534 | + dst_rule=pendulum.PRE_TRANSITION |
| 535 | + ) |
| 536 | + |
| 537 | + assert_datetime(dt, 2134, 10, 31, 2, 30) |
| 538 | + assert dt.utcoffset().total_seconds() == 3600 |
| 539 | + assert dt.dst() == timedelta() |
| 540 | + |
| 541 | + dt = tz.convert( |
| 542 | + pendulum.naive(2134, 10, 31, 2, 30), |
| 543 | + dst_rule=pendulum.POST_TRANSITION |
| 544 | + ) |
| 545 | + |
| 546 | + assert_datetime(dt, 2134, 10, 31, 2, 30) |
| 547 | + assert dt.utcoffset().total_seconds() == 3600 |
| 548 | + assert dt.dst() == timedelta() |
| 549 | + |
| 550 | + |
500 | 551 | def test_repr(): |
501 | 552 | tz = timezone('Europe/Paris') |
502 | 553 |
|
|
0 commit comments