-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
testdir.runpytest with a not expression doesn't skip tests #3427
Comments
GitMate.io thinks possibly related issues are #1549 (junit output doesn't add skipped tests into tests total), #502 (py.test --doctest-modules doesn't skip setup.py), #357 (Selecting tests with -k doesn't work as expected), #748 (pytest skip: short test summary info does not display actual test file), and #2975 (Pytest 3.3: tests being skipped without failing). |
Hi @davidemoro, Try passing import pytest
pytest_plugins = 'pytester'
@pytest.mark.parametrize("cli_options", [
('-k', "not test_skipped"),
('-k', 'dummy'),
])
def test_capture_skipped(testdir, cli_options):
testdir.makepyfile(r"""
import pytest
def test_skipped():
assert True
""")
result = testdir.runpytest(*cli_options)
result.assert_outcomes(skipped=1, passed=0) But your test still fails to me because in both cases the test won't be skipped, it will be deselected:
HTH! 👍 |
Thanks for your help @nicoddemus, it worked fine with Just a question: why deselected and not skipped? |
Hey @davidemoro, "deselected" means not run because of some command-line option "deselected" a collected test, while "skipped" means a test was skipped by code (a marker or |
Closing now, feel free to follow up with any other questions. 👍 |
Thanks, I got it! |
There is a test that reproduces the problem:
Can anyone verify if this is a
runpytest
bug or a problem of mine?Code example:
where:
Pip list:
OS version:
The text was updated successfully, but these errors were encountered: