Skip to content

Commit 7e418f2

Browse files
authored
Merge pull request #1217 from jremmet/pytest_stash
pytest.stash instead of protected member
2 parents 80595d5 + 13486c7 commit 7e418f2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

labgrid/pytestplugin/fixtures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from ..resource.remote import RemotePlace
88
from ..util.ssh import sshmanager
99
from ..logging import DEFAULT_FORMAT
10+
from .hooks import LABGRID_ENV_KEY
1011

1112
# pylint: disable=redefined-outer-name
1213

@@ -60,7 +61,7 @@ def env(request, record_testsuite_property):
6061
"""Return the environment configured in the supplied configuration file.
6162
It contains the targets contained in the configuration file.
6263
"""
63-
env = request.config._labgrid_env
64+
env = request.config.stash[LABGRID_ENV_KEY]
6465

6566
if not env:
6667
pytest.skip("missing environment config (use --lg-env)")

labgrid/pytestplugin/hooks.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from ..util.helper import processwrapper
99
from ..logging import StepFormatter, StepLogger
1010

11+
LABGRID_ENV_KEY = pytest.StashKey[Environment]()
12+
13+
1114
@pytest.hookimpl(tryfirst=True)
1215
def pytest_cmdline_main(config):
1316
def set_cli_log_level(level):
@@ -89,15 +92,15 @@ def pytest_configure(config):
8992
env = Environment(config_file=lg_env)
9093
if lg_coordinator is not None:
9194
env.config.set_option('crossbar_url', lg_coordinator)
92-
config._labgrid_env = env
95+
config.stash[LABGRID_ENV_KEY] = env
9396

9497
processwrapper.enable_logging()
9598

9699
@pytest.hookimpl()
97100
def pytest_collection_modifyitems(config, items):
98101
"""This function matches function feature flags with those found in the
99102
environment and disables the item if no match is found"""
100-
env = config._labgrid_env
103+
env = config.stash[LABGRID_ENV_KEY]
101104

102105
if not env:
103106
return

0 commit comments

Comments
 (0)