fix: reset LocalDataService singleton between tests#1784
Open
filippsatverily wants to merge 1 commit into
Open
fix: reset LocalDataService singleton between tests#1784filippsatverily wants to merge 1 commit into
filippsatverily wants to merge 1 commit into
Conversation
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.
Contributor
Author
|
@SFJohnson24 this allows bumping pytest. We could fix the tests that modify the singleton, but there are a lot of them, so I went with a reset per test. |
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 the collection order, exposing 29 test failures from stale singleton state.
This adds an autouse fixture in conftest.py that resets
LocalDataService._instance = Noneafter each test. This doesn't change the pytest version constraint — it just makes the test suite order-independent so pytest can be upgraded when ready.Tested scenarios: