forked from pact-foundation/pact-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
46 lines (37 loc) · 1.2 KB
/
conftest.py
File metadata and controls
46 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
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.
"""
from __future__ import annotations
import pytest
def pytest_addoption(parser: pytest.Parser) -> None:
"""
Define additional command line options for the Pact examples.
Args:
parser:
Parser used to register CLI options for the tests.
"""
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,
)
parser.addoption(
"--container",
action="store_true",
help="Run tests using a container",
)
def pytest_runtest_setup(item: pytest.Item) -> None:
"""
Hook into the test setup phase to apply container markers.
Args:
item:
Pytest item under execution, used to inspect markers and options.
"""
if "container" in item.keywords and not item.config.getoption("--container"):
pytest.skip("need --container to run this test")