Skip to content

Commit

Permalink
Testing: Export cratedb_service fixture as pytest11 entrypoint
Browse files Browse the repository at this point in the history
This way, for basic needs, corresponding boilerplate code does not need
to be provided by downstream projects.

When needing more configurability, you will need to define corresponding
alternative fixtures, and not use the built-in provided from.
  • Loading branch information
amotl committed Feb 9, 2024
1 parent 3a8e9bf commit f56f85e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ test = [
testing = [
"testcontainers<4",
]

[project.urls]
changelog = "https://github.com/crate-workbench/cratedb-toolkit/blob/main/CHANGES.rst"
documentation = "https://github.com/crate-workbench/cratedb-toolkit"
Expand All @@ -155,6 +154,8 @@ cratedb-retention = "cratedb_toolkit.retention.cli:cli"
cratedb-toolkit = "cratedb_toolkit.cli:cli"
ctk = "cratedb_toolkit.cli:cli"
migr8 = "cratedb_toolkit.io.mongodb.cli:main"
[project.entry-points.pytest11]
cratedb_service = "cratedb_toolkit.testing.pytest"

[tool.black]
line-length = 120
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def configure_database_schema(session_mocker, prune_environment):


@pytest.fixture(scope="session")
def cratedb_service():
def cratedb_custom_service():
"""
Provide a CrateDB service instance to the test suite.
"""
Expand All @@ -67,12 +67,12 @@ def cratedb_service():


@pytest.fixture(scope="function")
def cratedb(cratedb_service):
def cratedb(cratedb_custom_service):
"""
Provide a fresh canvas to each test case invocation, by resetting database content.
"""
cratedb_service.reset(tables=RESET_TABLES)
yield cratedb_service
cratedb_custom_service.reset(tables=RESET_TABLES)
yield cratedb_custom_service


@pytest.fixture
Expand Down

0 comments on commit f56f85e

Please sign in to comment.