Repository navigation
using pytest_configure hook prevents pytest --help from functioning at all
#13392
Replies: 1 comment
|
pytest --helpThe problem in the example is this line: config.getoption("")
If this is for a custom option, register it first: def pytest_addoption(parser):
parser.addoption(
"--my-option",
action="store",
default=None,
help="My custom option",
)
def pytest_configure(config):
value = config.getoption("--my-option")
if value is not None:
# configure whatever depends on the option
...Then: pytest --helpcan include your option in the help output without the configuration hook failing. More generally, So I would not try to prevent Please mark this answer as accepted if it helped, thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Using pytest 8.3.5
STR
conftest.pypytest --helpAt this point, the standard help printout is not triggered. Instead, the code within
pytest_configureis run. This is strange to me, as currently I have to remove mypytest_configurecode to print any help tips for pytest.Any tips for having both a
pytest_configurehook and the ability to print standard pytest help?All reactions