Skip to content
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

--ignore option doesn't work #846

Closed
olgert opened this issue Jul 15, 2015 · 7 comments
Closed

--ignore option doesn't work #846

olgert opened this issue Jul 15, 2015 · 7 comments

Comments

@olgert
Copy link

olgert commented Jul 15, 2015

I'm using Python 3.4.3 and pytest 2.7.2.
Running py.test --collect-only --ignore=path/to/file.py collects tests for me that should be ignored.

@The-Compiler
Copy link
Member

How can this be reproduced? Seems to work fine here:

$ cat test_foo.py
def test_foo():
    pass

$ py.test --collect-only
platform linux -- Python 3.4.3 -- py-1.4.30 -- pytest-2.7.2
collected 1 items 
<Module 'test_foo.py'>
  <Function 'test_foo'>

$ py.test --collect-only --ignore=test_foo.py
collected 0 items 

(I removed some lines from the output for brevity)

@olgert
Copy link
Author

olgert commented Jul 16, 2015

Hmm, this basic case works for me in freshly created virtualenv, but does not in my projects' virtualenv. It looks like some of installed packages make an influence on that.

@The-Compiler
Copy link
Member

I haven't looked at the implementation of --ignore, but that sounds odd. Can you show pip freeze in the affected virtualenv?

Random guess: Maybe you're running the pytest binary which comes with logilab-common which in turn comes with pylint? You'd notice by the lack of colors, for example. If that's the case, try python -m py.test instead.

@olgert
Copy link
Author

olgert commented Jul 16, 2015

Looks like I found that package pytest-gitignore==1.2 which overrides original pytest_ignore_collect(path, config). I'm not yet familiar with pytest's plugin model, but is it possible to inherit default behavior in overridden pytest_ignore_collect(path, config)? Or even better, just to own ignore handler into pipeline? This plugin is quite useful, though.

@nicoddemus
Copy link
Member

You can inherit the default behavior by using the new hookwrapper mechanism, for example:

@pytest.mark.hookwrapper
def pytest_ignore_collect(path, config):
    outcome = yield
    if not output.get_result():
        # not ignored by the default hook
        if git_ignore_check_path(path):
            outcome.force_result(True)

But this will have to be implemented in pytest-gitignore, so I suggest creating an issue or opening a PR there. 😄

Closing this as I think there's not much more to do here.

@tgs
Copy link

tgs commented Jul 17, 2015

@nicoddemus - thank you for the example code!

@nicoddemus
Copy link
Member

👍 😄

This was referenced Nov 17, 2022
This was referenced Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants