MCPcopy Create free account
hub / github.com/dateutil/dateutil / zoneinfo_cache

Function zoneinfo_cache

tests/test_tzfile.py:62–85  ·  view source on GitHub ↗

A fixture that extracts TZif files from a JSON file mapping timezone names to base64-encoded gzipped TZif data. The files are extracted into a temporary directory once per module and deleted afterwards. Returns: tuple: The path to the directory containing the extracted

(request)

Source from the content-addressed store, hash-verified

60
61@pytest.fixture(scope="module")
62def zoneinfo_cache(request):
63 """
64 A fixture that extracts TZif files from a JSON file mapping timezone names to
65 base64-encoded gzipped TZif data.
66
67 The files are extracted into a temporary directory once per module and
68 deleted afterwards.
69
70 Returns:
71 tuple: The path to the directory containing the extracted timezone
72 files, and the name of the data set.
73 """
74 input_file = os.path.join(
75 os.path.dirname(__file__),
76 "resources",
77 "data",
78 "zoneinfo_%s.json" % request.param,
79 )
80 cache_dir = tempfile.mkdtemp(prefix="zoneinfo_%s_" % request.param)
81 try:
82 extract_tzif_files(input_file, cache_dir)
83 yield os.path.abspath(cache_dir), request.param
84 finally:
85 shutil.rmtree(cache_dir)
86
87
88def extract_tzif_files(input_file, cache_dir):

Callers

nothing calls this directly

Calls 1

extract_tzif_filesFunction · 0.85

Tested by

no test coverage detected