Coverage for tests / conftest.py: 89%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-22 18:15 -0700

1"""shared test fixtures""" 

2 

3import shutil 

4from pathlib import Path 

5 

6import pytest 

7 

8TEMP_DIR = Path("tests/.temp") 

9 

10 

11@pytest.fixture(autouse=True, scope="session") 

12def _clean_temp_dir(): 

13 """Remove stale test artifacts before the test session. 

14 

15 Tests write to tests/.temp/<test_name>/ and don't clean up after themselves 

16 (each test uses a unique subdirectory so they don't collide). Wiping the 

17 directory at session start prevents stale files from a previous run from 

18 masking regressions -- e.g. a test that checks file existence could pass 

19 from leftover data even if the code that creates the files is broken. 

20 """ 

21 if TEMP_DIR.exists(): 

22 shutil.rmtree(TEMP_DIR) 

23 TEMP_DIR.mkdir(parents=True, exist_ok=True)