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)
| 60 | |
| 61 | @pytest.fixture(scope="module") |
| 62 | def 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 | |
| 88 | def extract_tzif_files(input_file, cache_dir): |
nothing calls this directly
no test coverage detected