| 1 | import sys |
| 2 | from pathlib import Path |
| 3 | from unittest import mock |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "skills" / "last30days" / "scripts")) |
| 8 | |
| 9 | |
| 10 | @pytest.fixture(autouse=True) |
| 11 | def _no_arctic_network(): |
| 12 | """Default the arctic-shift score lookup to a no-op so the suite never makes |
| 13 | a real network call. test_reddit_arctic overrides this fixture (same name) to |
| 14 | exercise the real lookup with http.get mocked.""" |
| 15 | with mock.patch("lib.reddit_arctic.fetch_scores", return_value={}): |
| 16 | yield |
| 17 | |
| 18 | |
| 19 | @pytest.fixture(autouse=True) |
| 20 | def _reset_probe_caches(): |
| 21 | """The doctor stack memoizes probe results in module-level dicts (safe for |
| 22 | the one-shot CLI process, wrong across tests). Clear them around every test |
| 23 | so a probe cached by one test can never leak into another.""" |
| 24 | from lib import health, xurl_x |
| 25 | |
| 26 | health.clear_dependency_probe_cache() |
| 27 | xurl_x.clear_availability_cache() |
| 28 | yield |
| 29 | health.clear_dependency_probe_cache() |
| 30 | xurl_x.clear_availability_cache() |
| 31 |