pytestconfig is now session-config as it is the same object during the

whole test run.  Fixes issue370
This commit is contained in:
holger krekel 2013-10-21 13:33:36 +02:00
parent 2eebe6c677
commit bc8c4b3ebd
3 changed files with 10 additions and 3 deletions

View File

@ -12,6 +12,9 @@ Changes between 2.4.2 and 2.4.3
properly so that the pkg_resources.resource_stream method works properly. properly so that the pkg_resources.resource_stream method works properly.
Fixes issue366. Thanks for the investigations and full PR to Jason R. Coombs. Fixes issue366. Thanks for the investigations and full PR to Jason R. Coombs.
- pytestconfig is now session-config as it is the same object during the
whole test run. Fixes issue370.
- avoid one surprising case of marker malfunction/confusion:: - avoid one surprising case of marker malfunction/confusion::
@pytest.mark.some(lambda arg: ...) @pytest.mark.some(lambda arg: ...)

View File

@ -157,7 +157,7 @@ def pytest_namespace():
'_fillfuncargs': fillfixtures} '_fillfuncargs': fillfixtures}
} }
@fixture() @fixture(scope="session")
def pytestconfig(request): def pytestconfig(request):
""" the pytest config object with access to command line opts.""" """ the pytest config object with access to command line opts."""
return request.config return request.config
@ -1566,8 +1566,8 @@ class FixtureManager:
continue # will raise FixtureLookupError at setup time continue # will raise FixtureLookupError at setup time
for fixturedef in faclist: for fixturedef in faclist:
if fixturedef.params is not None: if fixturedef.params is not None:
metafunc.parametrize(argname, fixturedef.params, indirect=True, metafunc.parametrize(argname, fixturedef.params,
scope=fixturedef.scope) indirect=True, scope=fixturedef.scope)
def pytest_collection_modifyitems(self, items): def pytest_collection_modifyitems(self, items):
# separate parametrized setups # separate parametrized setups

View File

@ -150,3 +150,7 @@ class TestReRunTests:
result.stdout.fnmatch_lines(""" result.stdout.fnmatch_lines("""
*2 passed* *2 passed*
""") """)
def test_pytestconfig_is_session_scoped():
from _pytest.python import pytestconfig
assert pytestconfig._pytestfixturefunction.scope == "session"