Skip to content

Commit 17e0323

Browse files
authored
Merge pull request #39 from BeyondEvil/beyondevil/use-pytest-stash
Feature: Use pytest.stash instead of protected member
2 parents 967e7f2 + a76f7e2 commit 17e0323

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGES.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Release Notes
22
-------------
33

4-
**2.1.0 (unreleased)**
4+
**3.0.0 (unreleased)**
5+
6+
* Use `pytest.stash` internally instead of `_variables`
57

68
* Switch to Hatch
79

src/pytest_variables/plugin.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def default(module, path, loader):
2121
return module.load(f)
2222

2323

24+
variables_key = pytest.StashKey[dict]()
25+
2426
parser_table = {
2527
"json": ("json", default),
2628
"hjson": ("hjson", default),
@@ -80,7 +82,7 @@ def _merge(a, b, path=None):
8082

8183

8284
def pytest_configure(config):
83-
config._variables = {}
85+
config.stash[variables_key] = {}
8486
paths = config.getoption("variables")
8587
loader = config.getini("yaml_loader")
8688
for path in paths:
@@ -104,10 +106,10 @@ def pytest_configure(config):
104106
if not isinstance(variables, dict):
105107
raise errors.ValueError("Unable to parse {0}".format(path))
106108

107-
reduce(_merge, [config._variables, variables])
109+
reduce(_merge, [config.stash[variables_key], variables])
108110

109111

110112
@pytest.fixture(scope="session")
111113
def variables(pytestconfig):
112114
"""Provide test variables from a specified file"""
113-
return pytestconfig._variables
115+
return pytestconfig.stash[variables_key]

0 commit comments

Comments
 (0)