From bc8c4b3ebd83e31dbc84c86541bf42a8e6f48120 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 21 Oct 2013 13:33:36 +0200 Subject: [PATCH] pytestconfig is now session-config as it is the same object during the whole test run. Fixes issue370 --- CHANGELOG | 3 +++ _pytest/python.py | 6 +++--- testing/python/integration.py | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1b414bc0a..43a86c141 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,9 @@ Changes between 2.4.2 and 2.4.3 properly so that the pkg_resources.resource_stream method works properly. 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:: @pytest.mark.some(lambda arg: ...) diff --git a/_pytest/python.py b/_pytest/python.py index fc957acaa..9aa000588 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -157,7 +157,7 @@ def pytest_namespace(): '_fillfuncargs': fillfixtures} } -@fixture() +@fixture(scope="session") def pytestconfig(request): """ the pytest config object with access to command line opts.""" return request.config @@ -1566,8 +1566,8 @@ class FixtureManager: continue # will raise FixtureLookupError at setup time for fixturedef in faclist: if fixturedef.params is not None: - metafunc.parametrize(argname, fixturedef.params, indirect=True, - scope=fixturedef.scope) + metafunc.parametrize(argname, fixturedef.params, + indirect=True, scope=fixturedef.scope) def pytest_collection_modifyitems(self, items): # separate parametrized setups diff --git a/testing/python/integration.py b/testing/python/integration.py index c8d9c4411..00e70df83 100644 --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -150,3 +150,7 @@ class TestReRunTests: result.stdout.fnmatch_lines(""" *2 passed* """) + +def test_pytestconfig_is_session_scoped(): + from _pytest.python import pytestconfig + assert pytestconfig._pytestfixturefunction.scope == "session"