fix issue403 : allow same-name parametrized functions within a collector
This commit is contained in:
parent
c9195a0f45
commit
b4797d6295
|
@ -1529,7 +1529,8 @@ class FixtureManager:
|
||||||
self._nodename2fixtureinfo = {}
|
self._nodename2fixtureinfo = {}
|
||||||
|
|
||||||
def getfixtureinfo(self, node, func, cls, funcargs=True):
|
def getfixtureinfo(self, node, func, cls, funcargs=True):
|
||||||
key = (node, func.__name__)
|
# node is the "collection node" for "func"
|
||||||
|
key = (node, func)
|
||||||
try:
|
try:
|
||||||
return self._nodename2fixtureinfo[key]
|
return self._nodename2fixtureinfo[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -630,6 +630,22 @@ class TestMetafuncFunctional:
|
||||||
"*3 passed*"
|
"*3 passed*"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_generate_same_function_names_issue403(self, testdir):
|
||||||
|
sub1 = testdir.makepyfile("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
def make_tests():
|
||||||
|
@pytest.mark.parametrize("x", range(2))
|
||||||
|
def test_foo(x):
|
||||||
|
pass
|
||||||
|
return test_foo
|
||||||
|
|
||||||
|
test_x = make_tests()
|
||||||
|
test_y = make_tests()
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run()
|
||||||
|
reprec.assertoutcome(passed=4)
|
||||||
|
|
||||||
|
|
||||||
class TestMarkersWithParametrization:
|
class TestMarkersWithParametrization:
|
||||||
pytestmark = pytest.mark.issue308
|
pytestmark = pytest.mark.issue308
|
||||||
|
|
Loading…
Reference in New Issue