-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
pytest local plugin not working: unknown hook 'pytest_disable_cov' #5169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The error is:
Looks like you want to use |
@blueyed The test did run and pass, but --no-cov option does not take effect, here is output of
my code attached: notes: .envrc is used to automate shell env of the proj (ref: |
Please try pytest_cmdline_preparse. |
See #5024 (comment). |
Also: just use |
After made the changes you have suggested, it still does not work:
updated code attached: |
Just run |
Also conftest is not in the zip?! |
Ah, you used |
Nope... tried append The reason I create a plugin is to dynamically disable coverage if it is running in python debug mode - debugger does not work properly when pytest runs with coverage (ref: |
Doesn't Also consider maybe running with coverage only on demand, i.e. create a |
If I directly pass
Also tried all your other suggestions, none of them working... Could there be a bug in pytest? Maybe caused by #935? |
I am not really sure what you're trying to achieve here: it sounds like you want to use pytest-cov not by default when developing or something like that? If you run
I would just not try adjusting args in that regard from the beginning. And then you could use e.g. |
I have mentioned the reason in one of my previous comments:
And
No, in the plugin I just print out the args without changing a bit. Basically pytest.ini:
In the CLI, I run |
Well.. you should decide if you want to see coverage all the time, or not - I'd rather only run it on CI or manually (i.e. via You are also mixing Just ensure that pytest's output is what you want ("plugins: cov-2.6.1, mypackage-0.0.0"). |
Nope, if I run pytest with coverage enabled through a debugger, I cannot hit breakpoint. The issue quoting from https://pytest-cov.readthedocs.io/en/latest/debuggers.html:
|
Oh.. for me Still, why do you want to use |
How does PyCharm invoke debugging, i.e. how does it run pytest then? |
I suspect @iamabigstone doesn't want to have different run configuration when debugging. Conftests will not work. With a custom plugin this will do the job: import pytest
@pytest.mark.tryfirst
def pytest_load_initial_conftests(early_config):
if is_debugging():
early_config.known_args_namespace.no_cov = True |
Actually, since pytest_cov bootstraps via a tryfirst pytest_load_initial_conftests, it may not work, depending on plugins ordering. You may need to use |
I have a pytest plugin in test folder's conftest.py:
for e.g.
the dirs look like:
Now if I run below from virtual env:
cd myrepo; python -m pytest test/test_something.py
it outputs:
pip list
from the virtual environment you are usingThe text was updated successfully, but these errors were encountered: