-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
topic: configrelated to config handling, argument parsing and config filerelated to config handling, argument parsing and config file
Description
I want to run pytest with coverage option only when the command is not launched inside pycharm. Previously I just added a hook in conftest.py and it was working well:
def pytest_cmdline_preparse(args):
if 'PYCHARM_HOSTED' not in os.environ:
args.append("--cov=waloupkg")
However the latest pytest calls this hook only after pytest-cov hooks have been already called and I'm unable to launch the cov pluggin as demonstrated below. In case 1) I do not get a coverage report while in case 2) I get one (not displayed here).
- This is what happen when I do not specify '--cov' on the command line expecting my hook to do it for me:
(toto) C:\Users\jchopard\Documents\eval\pkging\waloupkg
>pytest -s
cov: pytest_load_initial_conftests ['--maxfail=2', '-rf', '-s']
mine: pytest_cmdline_preparse
=============================================== test session starts ================================================
platform win32 -- Python 3.7.1, pytest-3.10.0, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\jchopard\Documents\eval\pkging\waloupkg, inifile: setup.cfg
plugins: cov-2.6.0
collected 1 item
- This is what happen when I explicitly specify '--cov' on the command line
(toto) C:\Users\jchopard\Documents\eval\pkging\waloupkg
>pytest -s --cov
cov: pytest_load_initial_conftests ['--maxfail=2', '-rf', '-s', '--cov']
cov: __init__
cov: start
mine: pytest_cmdline_preparse
=============================================== test session starts ================================================
platform win32 -- Python 3.7.1, pytest-3.10.0, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\jchopard\Documents\eval\pkging\waloupkg, inifile: setup.cfg
plugins: cov-2.6.0
collected 1 item
PS: I tried to use pytest_load_initial_conftests
instead of pytest_cmdline_preparse
but the hook was never called.
Metadata
Metadata
Assignees
Labels
topic: configrelated to config handling, argument parsing and config filerelated to config handling, argument parsing and config file