parent
530b0050b4
commit
1a79137d04
|
@ -361,7 +361,9 @@ class PyCollector(PyobjMixin, pytest.Collector):
|
||||||
yield Function(name=subname, parent=self,
|
yield Function(name=subname, parent=self,
|
||||||
callspec=callspec, callobj=funcobj,
|
callspec=callspec, callobj=funcobj,
|
||||||
fixtureinfo=fixtureinfo,
|
fixtureinfo=fixtureinfo,
|
||||||
keywords={callspec.id:True})
|
keywords={callspec.id:True},
|
||||||
|
originalname=name,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _marked(func, mark):
|
def _marked(func, mark):
|
||||||
|
@ -1471,7 +1473,7 @@ class Function(FunctionMixin, pytest.Item, fixtures.FuncargnamesCompatAttr):
|
||||||
_genid = None
|
_genid = None
|
||||||
def __init__(self, name, parent, args=None, config=None,
|
def __init__(self, name, parent, args=None, config=None,
|
||||||
callspec=None, callobj=NOTSET, keywords=None, session=None,
|
callspec=None, callobj=NOTSET, keywords=None, session=None,
|
||||||
fixtureinfo=None):
|
fixtureinfo=None, originalname=None):
|
||||||
super(Function, self).__init__(name, parent, config=config,
|
super(Function, self).__init__(name, parent, config=config,
|
||||||
session=session)
|
session=session)
|
||||||
self._args = args
|
self._args = args
|
||||||
|
@ -1493,6 +1495,12 @@ class Function(FunctionMixin, pytest.Item, fixtures.FuncargnamesCompatAttr):
|
||||||
self.fixturenames = fixtureinfo.names_closure
|
self.fixturenames = fixtureinfo.names_closure
|
||||||
self._initrequest()
|
self._initrequest()
|
||||||
|
|
||||||
|
#: original function name, without any decorations (for example
|
||||||
|
#: parametrization adds a ``"[...]"`` suffix to function names).
|
||||||
|
#:
|
||||||
|
#: .. versionadded:: 3.0
|
||||||
|
self.originalname = originalname
|
||||||
|
|
||||||
def _initrequest(self):
|
def _initrequest(self):
|
||||||
self.funcargs = {}
|
self.funcargs = {}
|
||||||
if self._isyieldedfunction():
|
if self._isyieldedfunction():
|
||||||
|
|
|
@ -634,6 +634,15 @@ class TestFunction:
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.stdout.fnmatch_lines('* 3 passed in *')
|
result.stdout.fnmatch_lines('* 3 passed in *')
|
||||||
|
|
||||||
|
def test_function_original_name(self, testdir):
|
||||||
|
items = testdir.getitems("""
|
||||||
|
import pytest
|
||||||
|
@pytest.mark.parametrize('arg', [1,2])
|
||||||
|
def test_func(arg):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
assert [x.originalname for x in items] == ['test_func', 'test_func']
|
||||||
|
|
||||||
|
|
||||||
class TestSorting:
|
class TestSorting:
|
||||||
def test_check_equality(self, testdir):
|
def test_check_equality(self, testdir):
|
||||||
|
|
Loading…
Reference in New Issue