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

Failure on Python 2.7.17, pytest-3.10.1 #5

Open
jayvdb opened this issue Oct 11, 2020 · 0 comments
Open

Failure on Python 2.7.17, pytest-3.10.1 #5

jayvdb opened this issue Oct 11, 2020 · 0 comments

Comments

@jayvdb
Copy link

jayvdb commented Oct 11, 2020

I havent investigated what is going on yet. Possibly the minimum pytest version is too low? I notice tox.ini isnt testing against the minimum pytest version.

platform linux2 -- Python 2.7.17, pytest-3.10.1, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python2
cachedir: .pytest_cache
rootdir: /home/abuild/rpmbuild/BUILD/pytest-fixture-marker-1.0.0, inifile:
plugins: fixture-marker-1.0.0
collecting ... collected 5 items

tests/test_fixture_marker.py::test_help_message PASSED                   [ 20%]
tests/test_fixture_marker.py::test_mark_fixture[default] FAILED          [ 40%]
tests/test_fixture_marker.py::test_mark_fixture[expression-suffix] FAILED [ 60%]
tests/test_fixture_marker.py::test_mark_fixture[arg] FAILED              [ 80%]
tests/test_fixture_marker.py::test_mark_fixture[arg-has-precedence-over-ini] FAILED [100%]

=================================== FAILURES ===================================
__________________________ test_mark_fixture[default] __________________________

testdir = <Testdir local('/tmp/pytest-of-abuild/pytest-0/test_mark_fixture0')>
args = ['-m fixture_foobar'], ini = None

    @pytest.mark.parametrize(
        "args,ini",
        [
            pytest.param(["-m fixture_foobar"], None, id="default"),
            pytest.param(["-m foobar_suffix"], "{}_suffix", id="expression-suffix"),
            pytest.param(
                ["-m foobar_arg", "--fixture-marker-expression={}_arg"], None, id="arg"
            ),
            pytest.param(
                ["-m foobar_arg", "--fixture-marker-expression={}_arg"],
                "{}_ini",
                id="arg-has-precedence-over-ini",
            ),
        ],
    )
    def test_mark_fixture(testdir, args, ini):
        """Test the tests are marked as expected"""
    
        if ini is not None:
            testdir.makeini(
                """
                [pytest]
                fixture_marker_expression = {}
                """.format(
                    ini
                )
            )
        # create a temporary pytest test module
        testdir.makepyfile(
            """
            import pytest
            @pytest.fixture()
            def foobar():
                pass
    
            def test_uses(foobar):
                pass
    
            def test_not():
                pass
            """
        )
    
        assert isinstance(
            args, (list, tuple)
        )  # cause I already shot myself in the foot by not having a trailing comma
    
        # run pytest with the following cmd args
        result = testdir.runpytest("-v", "--strict-markers", *args)
    
        # fnmatch_lines does an assertion internally
        # check we collect 2 but only run the test using the fixture
        result.stdout.fnmatch_lines(
>           ["*collected 2 items / 1 deselected*", "*::test_uses PASSED*"]
        )
E       Failed: nomatch: '*collected 2 items / 1 deselected*'
E           and: u''
E       remains unmatched: '*collected 2 items / 1 deselected*'

/home/abuild/rpmbuild/BUILD/pytest-fixture-marker-1.0.0/tests/test_fixture_marker.py:66: Failed
----------------------------- Captured stderr call -----------------------------
usage: pytest-2.7 [options] [file_or_dir] [file_or_dir] [...]
pytest-2.7: error: unrecognized arguments: --strict-markers
  inifile: None
  rootdir: /tmp/pytest-of-abuild/pytest-0/test_mark_fixture0
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

1 participant