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 individual tests #3198

Closed
uSpike opened this issue Feb 9, 2018 · 3 comments
Closed

Ignore individual tests #3198

uSpike opened this issue Feb 9, 2018 · 3 comments

Comments

@uSpike
Copy link
Member

@uSpike uSpike commented Feb 9, 2018

It would be useful for my workflow to be able to ignore specific tests while still collecting an entire directory.

For example, I have:

tests/
    test_a.py # contains test_foo(), test_bar()
    test_b.py # contains test_baz(), test_buz()

I can currently use --ignore to ignore an entire file, but not a specific test. If I want to run every test except for test_a.py::test_foo I will have a very long command line.

I propose to accept test ids with --ignore:

$ pytest tests --ignore tests/test_a.py::test_foo
$ pytest tests --ignore tests/test_a.py::test_foo[param]

Thoughts? I'd be glad to submit a PR.

@nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Feb 9, 2018

Seems useful at first sight. Feel free to submit a PR. 👍

uSpike pushed a commit to uSpike/pytest that referenced this issue Feb 9, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 9, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 9, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 9, 2018
@uSpike uSpike mentioned this issue Feb 9, 2018
5 of 5 tasks complete
uSpike added a commit to uSpike/pytest that referenced this issue Feb 12, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 15, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 15, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 15, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 16, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 16, 2018
uSpike added a commit to uSpike/pytest that referenced this issue Feb 16, 2018
@uSpike
Copy link
Member Author

@uSpike uSpike commented Feb 16, 2018

I submitted #3201 with a different implementation than I proposed. I opted to add --deselect [node_prefix] which would deselect tests during collection. I came to the conclusion that --ignore is too tied to paths to be extended for individual tests. What I wanted to implement was a way to ignore individual nodeids, and other options like -k didn't quite fit the bill.

@Hi-Angel
Copy link

@Hi-Angel Hi-Angel commented Aug 17, 2020

FTR, I figured there's a more convenient way to ignore tests, which supports a pattern match, that is -k "not test_foo"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.