Skip to content

Commit

Permalink
chore: scope postgres_container fixture to class
Browse files Browse the repository at this point in the history
The postgres_container fixture was scoped to 'session', effectively all
tests. This meant that the state in the database was shared across all
tests. This is good for speeding up tests, because the container must
only be constructed once, but bad for tests being independent (because
they rely on shared state).

This change scopes the postgres_container to 'class', and adds a new
class to group tests which can be run together with the same database
state. This balances the tradeoff between "every test must build
everything from scratch" and "tests are very slow".
  • Loading branch information
JamesGuthrie committed Nov 14, 2024
1 parent ec53bef commit 12c1780
Show file tree
Hide file tree
Showing 2 changed files with 253 additions and 259 deletions.
2 changes: 1 addition & 1 deletion projects/pgai/tests/vectorizer/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def vcr_():
)


@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def postgres_container():
extension_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), "../../../extension/")
Expand Down
Loading

0 comments on commit 12c1780

Please sign in to comment.