merge
This commit is contained in:
commit
3b85a56db2
|
@ -1,6 +1,8 @@
|
||||||
Changes between 2.3.5 and 2.4.DEV
|
Changes between 2.3.5 and 2.4.DEV
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
- fix issue336: autouse fixture in plugins should work again.
|
||||||
|
|
||||||
- change to use hyphen-separated long options but keep the old spelling
|
- change to use hyphen-separated long options but keep the old spelling
|
||||||
backward compatible. py.test -h will only show the hyphenated version,
|
backward compatible. py.test -h will only show the hyphenated version,
|
||||||
for example "--collect-only" but "--collectonly" will remain valid as well
|
for example "--collect-only" but "--collectonly" will remain valid as well
|
||||||
|
|
|
@ -1626,18 +1626,18 @@ class FixtureManager:
|
||||||
unittest=unittest)
|
unittest=unittest)
|
||||||
faclist = self._arg2fixturedefs.setdefault(name, [])
|
faclist = self._arg2fixturedefs.setdefault(name, [])
|
||||||
if not fixturedef.has_location:
|
if not fixturedef.has_location:
|
||||||
# All Nones are at the front so this inserts the
|
# All fixturedefs with no location are at the front
|
||||||
# current fixturedef after the existing fixturedefs
|
# so this inserts the current fixturedef after the
|
||||||
# from external plugins but before the fixturedefs
|
# existing fixturedefs from external plugins but
|
||||||
# provided in conftests.
|
# before the fixturedefs provided in conftests.
|
||||||
i = faclist.count(None)
|
i = len([f for f in faclist if not f.has_location])
|
||||||
else:
|
else:
|
||||||
i = len(faclist) # append
|
i = len(faclist) # append
|
||||||
faclist.insert(i, fixturedef)
|
faclist.insert(i, fixturedef)
|
||||||
if marker.autouse:
|
if marker.autouse:
|
||||||
autousenames.append(name)
|
autousenames.append(name)
|
||||||
if autousenames:
|
if autousenames:
|
||||||
self._nodeid_and_autousenames.append((nodeid, autousenames))
|
self._nodeid_and_autousenames.append((nodeid or '', autousenames))
|
||||||
|
|
||||||
def getfixturedefs(self, argname, nodeid):
|
def getfixturedefs(self, argname, nodeid):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -173,7 +173,7 @@ class TestFillFixtures:
|
||||||
result = testdir.runpytest(testfile)
|
result = testdir.runpytest(testfile)
|
||||||
result.stdout.fnmatch_lines(["*1 passed*"])
|
result.stdout.fnmatch_lines(["*1 passed*"])
|
||||||
|
|
||||||
def test_extend_fixture_conftest_plugin(request, testdir):
|
def test_extend_fixture_conftest_plugin(self, testdir):
|
||||||
testdir.makepyfile(testplugin="""
|
testdir.makepyfile(testplugin="""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -198,6 +198,52 @@ class TestFillFixtures:
|
||||||
result = testdir.runpytest('-s')
|
result = testdir.runpytest('-s')
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
|
||||||
|
def test_extend_fixture_plugin_plugin(self, testdir):
|
||||||
|
# Two plugins should extend each order in loading order
|
||||||
|
testdir.makepyfile(testplugin0="""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def foo():
|
||||||
|
return 7
|
||||||
|
""")
|
||||||
|
testdir.makepyfile(testplugin1="""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def foo(foo):
|
||||||
|
return foo + 7
|
||||||
|
""")
|
||||||
|
testdir.syspathinsert()
|
||||||
|
testdir.makepyfile("""
|
||||||
|
pytest_plugins = ['testplugin0', 'testplugin1']
|
||||||
|
|
||||||
|
def test_foo(foo):
|
||||||
|
assert foo == 14
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest()
|
||||||
|
assert result.ret == 0
|
||||||
|
|
||||||
|
def test_autouse_fixture_plugin(self, testdir):
|
||||||
|
# A fixture from a plugin has no baseid set, which screwed up
|
||||||
|
# the autouse fixture handling.
|
||||||
|
testdir.makepyfile(testplugin="""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def foo(request):
|
||||||
|
request.function.foo = 7
|
||||||
|
""")
|
||||||
|
testdir.syspathinsert()
|
||||||
|
testdir.makepyfile("""
|
||||||
|
pytest_plugins = 'testplugin'
|
||||||
|
|
||||||
|
def test_foo(request):
|
||||||
|
assert request.function.foo == 7
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest()
|
||||||
|
assert result.ret == 0
|
||||||
|
|
||||||
def test_funcarg_lookup_error(self, testdir):
|
def test_funcarg_lookup_error(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
def test_lookup_error(unknown):
|
def test_lookup_error(unknown):
|
||||||
|
|
Loading…
Reference in New Issue