From 947c688df27d97148bda1b685d36f9462ec114ca Mon Sep 17 00:00:00 2001 From: Filipp Shpomer Date: Tue, 23 Jun 2026 15:32:25 -0700 Subject: [PATCH] fix: reset LocalDataService singleton between tests Several tests mutate the LocalDataService singleton (overwriting get_datasets, get_dataset, dataset_implementation, etc.) without restoring the original state. With pytest <8 the default collection order happened to run test_rules_engine.py before the mutating tests, masking the issue. Pytest 9 changed collection order, exposing 29 failures from stale singleton state. Adding an autouse fixture that resets the singleton after each test. --- tests/conftest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index c2f4c1d8f..780f03edf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,6 +42,12 @@ def run_regression_tests(request): return request.config.getoption("-m") == "regression" +@pytest.fixture(autouse=True) +def _reset_data_service_singleton(): + yield + LocalDataService._instance = None + + def mock_get_dataset(dataset_name): dataframe_map = { "ae.xpt": PandasDataset.from_dict(