-
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default to own .fold when calling .replace()
- Loading branch information
Showing
3 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import pendulum | ||
|
||
from ..conftest import assert_datetime | ||
|
||
|
||
def test_replace_tzinfo_dls_off(): | ||
utc = pendulum.datetime(2016, 3, 27, 0, 30) # 30 min before DLS turning on | ||
in_paris = utc.in_tz("Europe/Paris") | ||
|
||
assert_datetime(in_paris, 2016, 3, 27, 1, 30, 0) | ||
|
||
in_paris = in_paris.replace(second=1) | ||
|
||
assert_datetime(in_paris, 2016, 3, 27, 1, 30, 1) | ||
assert not in_paris.is_dst() | ||
assert in_paris.offset == 3600 | ||
assert in_paris.timezone_name == "Europe/Paris" | ||
|
||
|
||
def test_replace_tzinfo_dls_transitioning_on(): | ||
utc = pendulum.datetime(2016, 3, 27, 1, 30) # In middle of turning on | ||
in_paris = utc.in_tz("Europe/Paris") | ||
|
||
assert_datetime(in_paris, 2016, 3, 27, 3, 30, 0) | ||
|
||
in_paris = in_paris.replace(second=1) | ||
|
||
assert_datetime(in_paris, 2016, 3, 27, 3, 30, 1) | ||
assert in_paris.is_dst() | ||
assert in_paris.offset == 7200 | ||
assert in_paris.timezone_name == "Europe/Paris" | ||
|
||
|
||
def test_replace_tzinfo_dls_on(): | ||
utc = pendulum.datetime(2016, 10, 30, 0, 30) # 30 min before DLS turning off | ||
in_paris = utc.in_tz("Europe/Paris") | ||
|
||
assert_datetime(in_paris, 2016, 10, 30, 2, 30, 0) | ||
|
||
in_paris = in_paris.replace(second=1) | ||
|
||
assert_datetime(in_paris, 2016, 10, 30, 2, 30, 1) | ||
assert in_paris.is_dst() | ||
assert in_paris.offset == 7200 | ||
assert in_paris.timezone_name == "Europe/Paris" | ||
|
||
|
||
def test_replace_tzinfo_dls_transitioning_off(): | ||
utc = pendulum.datetime(2016, 10, 30, 1, 30) # In the middle of turning off | ||
in_paris = utc.in_tz("Europe/Paris") | ||
|
||
assert_datetime(in_paris, 2016, 10, 30, 2, 30, 0) | ||
|
||
in_paris = in_paris.replace(second=1) | ||
|
||
assert_datetime(in_paris, 2016, 10, 30, 2, 30, 1) | ||
assert not in_paris.is_dst() | ||
assert in_paris.offset == 3600 | ||
assert in_paris.timezone_name == "Europe/Paris" |