Create temporary cache for testing.
(tmp_path)
| 10 | |
| 11 | @pytest.fixture |
| 12 | def temp_cache(tmp_path): |
| 13 | """Create temporary cache for testing.""" |
| 14 | cache = ScanCache(ttl_seconds=3600) |
| 15 | cache.cache_dir = tmp_path / "cache" |
| 16 | cache.cache_dir.mkdir(parents=True, exist_ok=True) |
| 17 | cache._memory_cache.clear() # Clear memory cache before test |
| 18 | # Clear any existing cache files |
| 19 | for cache_file in cache.cache_dir.glob("*.json"): |
| 20 | cache_file.unlink() |
| 21 | yield cache |
| 22 | cache._memory_cache.clear() # Clear memory cache after test |
| 23 | # Clean up cache files after test |
| 24 | for cache_file in cache.cache_dir.glob("*.json"): |
| 25 | cache_file.unlink() |
| 26 | |
| 27 | |
| 28 | @pytest.fixture |