blob: a19ba9a0f731b2244ae82da06aa989e02515374d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import os
import pytest
from pendulum.tz.zoneinfo.exceptions import InvalidTimezone
from pendulum.tz.zoneinfo.exceptions import InvalidZoneinfoFile
from pendulum.tz.zoneinfo.reader import Reader
from pendulum.tz.zoneinfo.timezone import Timezone
def test_read_for_bad_timezone():
reader = Reader()
with pytest.raises(InvalidTimezone):
reader.read_for("---NOT A TIMEZONE---")
def test_read_for_valid():
reader = Reader()
tz = reader.read_for("America/Toronto")
assert isinstance(tz, Timezone)
def test_read():
reader = Reader()
local_path = os.path.join(os.path.split(__file__)[0], "..", "..")
tz_file = os.path.join(local_path, "fixtures", "tz", "Paris")
tz = reader.read(tz_file)
assert len(tz.transitions) > 0
def test_read_invalid():
reader = Reader()
local_path = os.path.join(os.path.split(__file__)[0], "..")
tz_file = os.path.join(local_path, "fixtures", "tz", "NOT_A_TIMEZONE")
with pytest.raises(InvalidZoneinfoFile):
reader.read(tz_file)
def test_set_transitions_for_no_transition_database_file():
reader = Reader()
tz = reader.read_for("Etc/UTC")
assert len(tz.transitions) == 1
|