forked from sdispater/pytzdata
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_tz_path.py
More file actions
45 lines (28 loc) · 958 Bytes
/
Copy pathtest_tz_path.py
File metadata and controls
45 lines (28 loc) · 958 Bytes
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
# -*- coding: utf-8 -*-
import os
import pytest
from pytzdata import tz_path, set_directory
from pytzdata.exceptions import TimezoneNotFound
def setup_module(module):
if 'PYTZDATA_TZDATADIR' in os.environ:
del os.environ['PYTZDATA_TZDATADIR']
set_directory()
def teardown_module(module):
if 'PYTZDATA_TZDATADIR' in os.environ:
del os.environ['PYTZDATA_TZDATADIR']
set_directory()
def test_tz_path():
here = os.path.realpath(os.path.dirname(__file__))
filepath = os.path.realpath(
os.path.join(here, '..', 'pytzdata', 'zoneinfo', 'Europe', 'Paris')
)
assert filepath == tz_path('Europe/Paris')
def test_tz_path_not_found():
with pytest.raises(TimezoneNotFound):
tz_path('Invalid')
def test_tz_path_invalid_name():
with pytest.raises(ValueError):
tz_path('Europe/../Paris')
def test_tz_path_empty_string():
with pytest.raises(ValueError):
tz_path('')