Skip to content

Search tests do not use clean_store fixture causing test pollution #12

@anxkhn

Description

@anxkhn

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

  1. Open tests/test_search.py.
  2. Notice neither test_search_with_query nor test_search_empty_query accepts clean_store as a parameter.
  3. Run: pytest tests/ -v and notice the search tests depend on the order they run in.
  4. 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

  • Both test functions in test_search.py use the clean_store fixture
  • Tests pass regardless of execution order
  • Running pytest tests/ -v gives consistent results

Suggested approach

  1. Open tests/test_search.py.
  2. Add clean_store as a parameter to both test functions:
    def test_search_with_query(clean_store):
  3. 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.
  4. Run pytest tests/ -v multiple times to confirm consistent results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstestsTest improvements or fixes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions