Context
The tests in tests/test_search.py directly mutate the shared profile_store dictionary without using the clean_store fixture defined in conftest.py. This means data from one test leaks into subsequent tests, causing unreliable results depending on test execution order.
Steps to reproduce
- Open
tests/test_search.py.
- Notice neither
test_search_with_query nor test_search_empty_query accepts clean_store as a parameter.
- Run:
pytest tests/ -v and notice the search tests depend on the order they run in.
- If you run
pytest tests/test_search.py -v alone, the store may contain stale data from the first test when the second test runs.
Expected behavior
Each test should start with a clean store by using the clean_store fixture, ensuring tests are independent and deterministic.
Actual behavior
Tests directly write to profile_store without cleanup. Data accumulates across tests.
Files
tests/test_search.py -- both test functions
tests/conftest.py -- the clean_store fixture (for reference)
Acceptance criteria
Suggested approach
- Open
tests/test_search.py.
- Add
clean_store as a parameter to both test functions:
def test_search_with_query(clean_store):
- Update the test to use
client.post(...) to create profiles through the API instead of directly mutating profile_store, or keep direct store mutation but rely on the fixture for cleanup.
- Run
pytest tests/ -v multiple times to confirm consistent results.
Context
The tests in
tests/test_search.pydirectly mutate the sharedprofile_storedictionary without using theclean_storefixture defined inconftest.py. This means data from one test leaks into subsequent tests, causing unreliable results depending on test execution order.Steps to reproduce
tests/test_search.py.test_search_with_querynortest_search_empty_queryacceptsclean_storeas a parameter.pytest tests/ -vand notice the search tests depend on the order they run in.pytest tests/test_search.py -valone, the store may contain stale data from the first test when the second test runs.Expected behavior
Each test should start with a clean store by using the
clean_storefixture, ensuring tests are independent and deterministic.Actual behavior
Tests directly write to
profile_storewithout cleanup. Data accumulates across tests.Files
tests/test_search.py-- both test functionstests/conftest.py-- theclean_storefixture (for reference)Acceptance criteria
test_search.pyuse theclean_storefixturepytest tests/ -vgives consistent resultsSuggested approach
tests/test_search.py.clean_storeas a parameter to both test functions:client.post(...)to create profiles through the API instead of directly mutatingprofile_store, or keep direct store mutation but rely on the fixture for cleanup.pytest tests/ -vmultiple times to confirm consistent results.