Skip to content

Commit

Permalink
chore(test): move pytest cli args definition
Browse files Browse the repository at this point in the history
The `--broker-url` PyTest CLI argument is used by the examples to
determine whether a Broker is automatically launched, or whether an
existing broker is used.

All PyTest CLI arguments _must_ be defined in the root directory of the
project. As a result, the previous location where these arguments were
defined meant that the examples could only be launched of PyTest was
specifically pointed at the `examples/` directory.

This commit moves the definition to the root directory, thereby unifying
the `examples/` with the remaining tests.

Signed-off-by: JP-Ellis <josh@jpellis.me>
  • Loading branch information
JP-Ellis committed Oct 10, 2023
1 parent d4121df commit 58d64f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
21 changes: 21 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Global PyTest configuration.
This file is automatically loaded by PyTest before running any tests and is used
to define global fixtures and command line options. Command line options can
only be defined in this file.
"""

import pytest


def pytest_addoption(parser: pytest.Parser) -> None:
"""Define additional command lines to customise the examples."""
parser.addoption(
"--broker-url",
help=(
"The URL of the broker to use. If this option has been given, the container"
" will _not_ be started."
),
type=str,
)
12 changes: 0 additions & 12 deletions examples/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
EXAMPLE_DIR = Path(__file__).parent.resolve()


def pytest_addoption(parser: pytest.Parser) -> None:
"""Define additional command lines to customise the examples."""
parser.addoption(
"--broker-url",
help=(
"The URL of the broker to use. If this option has been given, the container"
" will _not_ be started."
),
type=str,
)


@pytest.fixture(scope="session")
def broker(request: pytest.FixtureRequest) -> Generator[URL, Any, None]:
"""
Expand Down

0 comments on commit 58d64f4

Please sign in to comment.