Test case for overriding autouse fixtures
Test case for overriding autouse fixture with a parametrized fixture. The test covers the problem explained in the issue 1601 Adding Diego Russo to AUTHORS
This commit is contained in:
parent
38e0e08074
commit
1704b7d265
1
AUTHORS
1
AUTHORS
|
@ -34,6 +34,7 @@ Dave Hunt
|
||||||
David Díaz-Barquero
|
David Díaz-Barquero
|
||||||
David Mohr
|
David Mohr
|
||||||
David Vierra
|
David Vierra
|
||||||
|
Diego Russo
|
||||||
Edison Gustavo Muenz
|
Edison Gustavo Muenz
|
||||||
Eduardo Schettino
|
Eduardo Schettino
|
||||||
Elizaveta Shashkova
|
Elizaveta Shashkova
|
||||||
|
|
|
@ -336,6 +336,38 @@ class TestFillFixtures:
|
||||||
result = testdir.runpytest(testfile)
|
result = testdir.runpytest(testfile)
|
||||||
result.stdout.fnmatch_lines(["*3 passed*"])
|
result.stdout.fnmatch_lines(["*3 passed*"])
|
||||||
|
|
||||||
|
def test_override_autouse_fixture_with_parametrized_fixture_conftest_conftest(self, testdir):
|
||||||
|
"""Test override of the autouse fixture with parametrized one on the conftest level.
|
||||||
|
This test covers the issue explained in issue 1601
|
||||||
|
"""
|
||||||
|
testdir.makeconftest("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def spam():
|
||||||
|
return 'spam'
|
||||||
|
""")
|
||||||
|
subdir = testdir.mkpydir('subdir')
|
||||||
|
subdir.join("conftest.py").write(_pytest._code.Source("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture(params=[1, 2, 3])
|
||||||
|
def spam(request):
|
||||||
|
return request.param
|
||||||
|
"""))
|
||||||
|
testfile = subdir.join("test_spam.py")
|
||||||
|
testfile.write(_pytest._code.Source("""
|
||||||
|
params = {'spam': 1}
|
||||||
|
|
||||||
|
def test_spam(spam):
|
||||||
|
assert spam == params['spam']
|
||||||
|
params['spam'] += 1
|
||||||
|
"""))
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines(["*3 passed*"])
|
||||||
|
result = testdir.runpytest(testfile)
|
||||||
|
result.stdout.fnmatch_lines(["*3 passed*"])
|
||||||
|
|
||||||
def test_autouse_fixture_plugin(self, testdir):
|
def test_autouse_fixture_plugin(self, testdir):
|
||||||
# A fixture from a plugin has no baseid set, which screwed up
|
# A fixture from a plugin has no baseid set, which screwed up
|
||||||
# the autouse fixture handling.
|
# the autouse fixture handling.
|
||||||
|
|
Loading…
Reference in New Issue