fix issue403 : allow same-name parametrized functions within a collector

This commit is contained in:
holger krekel 2013-12-16 07:47:59 +01:00
parent c9195a0f45
commit b4797d6295
2 changed files with 18 additions and 1 deletions

View File

@ -1529,7 +1529,8 @@ class FixtureManager:
self._nodename2fixtureinfo = {}
def getfixtureinfo(self, node, func, cls, funcargs=True):
key = (node, func.__name__)
# node is the "collection node" for "func"
key = (node, func)
try:
return self._nodename2fixtureinfo[key]
except KeyError:

View File

@ -630,6 +630,22 @@ class TestMetafuncFunctional:
"*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:
pytestmark = pytest.mark.issue308