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

Applying multiple skipifs to parametrized test using param(marks=[]) is order dependent #3368

Closed
KevKeating opened this issue Apr 4, 2018 · 3 comments
Labels
topic: marks related to marks, either the general marks or builtin topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed

Comments

@KevKeating
Copy link

If I execute

import pytest


@pytest.mark.parametrize(
    "param",
    ["foo",
     pytest.param("bar", marks=[pytest.mark.skipif(False, reason=""),
                                pytest.mark.skipif(True, reason="")])])
def test_that_passes(param):
    assert param == "foo"


@pytest.mark.parametrize(
    "param",
    ["foo",
     pytest.param("bar", marks=[pytest.mark.skipif(True, reason=""),
                                pytest.mark.skipif(False, reason="")])])
def test_that_fails(param):
    assert param == "foo"

with Python 3.6.3 and pytest 3.5 on Windows 10 64-bit, then I get

============================= test session starts =============================
platform win32 -- Python 3.6.3, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: D:\Schrodinger-Kevin\pytest_bug, inifile:
collected 4 items

pytest_bug.py .s.F                                                       [100%]

================================== FAILURES ===================================
____________________________ test_that_fails[bar] _____________________________

param = 'bar'

    @pytest.mark.parametrize(
        "param",
        ["foo",
         pytest.param("bar", marks=[pytest.mark.skipif(True, reason=""),
                                    pytest.mark.skipif(False, reason="")])])
    def test_that_fails(param):
>       assert param == "foo"
E       AssertionError: assert 'bar' == 'foo'
E         - bar
E         + foo

pytest_bug.py:19: AssertionError
================ 1 failed, 2 passed, 1 skipped in 0.07 seconds ================

The "bar" version of the test is skipped in test_that_passes, but it's executed in test_that_fails. The only difference between these two tests is the order of the skipif marks in the pytest.param argument. I would expect the "bar" version of both tests to be skipped since they both have a skipif(True) mark applied. I think this is a slightly different issue than #1296, but presumably related.

@pytestbot pytestbot added topic: marks related to marks, either the general marks or builtin topic: parametrize related to @pytest.mark.parametrize labels Apr 4, 2018
@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #379 (Can't not apply multiple markers to individual test when using parametrize), #552 (Can't mark.xfail a callable test param), #2846 (Unexpected order of tests using parameterized fixtures), #473 (Cannot use @mark and multiple @patch class decorators), and #2703 (Multiple use of fixture in a single test).

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Apr 4, 2018
@RonnyPfannschmidt
Copy link
Member

looks like yet another mark issue - please take a look if its fixed by #3317

@RonnyPfannschmidt
Copy link
Member

actually its indeed a duplicate and fixed in #3317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: marks related to marks, either the general marks or builtin topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants