allow to use pytest.fixture decorator on old-style pytest_funcarg__NAME definitions.
This commit is contained in:
parent
bd320951e6
commit
817b175870
|
@ -93,6 +93,9 @@ Unreleased
|
||||||
|
|
||||||
- fix verbose reporting for @mock'd test functions
|
- fix verbose reporting for @mock'd test functions
|
||||||
|
|
||||||
|
- allow @pytest.fixture marked pytest_funcarg__foo functions
|
||||||
|
so that pylint errors can be avoided.
|
||||||
|
|
||||||
Changes between 2.4.1 and 2.4.2
|
Changes between 2.4.1 and 2.4.2
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1660,8 +1660,9 @@ class FixtureManager:
|
||||||
# magic globals with __getattr__ might have got us a wrong
|
# magic globals with __getattr__ might have got us a wrong
|
||||||
# fixture attribute
|
# fixture attribute
|
||||||
continue
|
continue
|
||||||
else:
|
elif name.startswith(self._argprefix):
|
||||||
assert not name.startswith(self._argprefix)
|
# let's allso fixture-marked pytest_funcarg__ prefixed functions
|
||||||
|
name = name[len(self._argprefix):]
|
||||||
fixturedef = FixtureDef(self, nodeid, name, obj,
|
fixturedef = FixtureDef(self, nodeid, name, obj,
|
||||||
marker.scope, marker.params,
|
marker.scope, marker.params,
|
||||||
yieldctx=marker.yieldctx,
|
yieldctx=marker.yieldctx,
|
||||||
|
|
|
@ -195,3 +195,16 @@ class TestReRunTests:
|
||||||
def test_pytestconfig_is_session_scoped():
|
def test_pytestconfig_is_session_scoped():
|
||||||
from _pytest.python import pytestconfig
|
from _pytest.python import pytestconfig
|
||||||
assert pytestconfig._pytestfixturefunction.scope == "session"
|
assert pytestconfig._pytestfixturefunction.scope == "session"
|
||||||
|
|
||||||
|
def test_funcarg_prefix_and_marker(testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import pytest
|
||||||
|
@pytest.fixture
|
||||||
|
def pytest_funcarg__foo():
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def test_hello(foo):
|
||||||
|
assert foo == 1
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run()
|
||||||
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
Loading…
Reference in New Issue