Skip to content

Commit 6f3dd9d

Browse files
committed
test_report_context -> test_report_context_registry
This way we are consistent with the other registries
1 parent 02296c2 commit 6f3dd9d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/pytest_bdd/cucumber_json.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import time
99
import typing
1010

11-
from .reporting import test_report_context
11+
from .reporting import test_report_context_registry
1212

1313
if typing.TYPE_CHECKING:
1414
from typing import Any
@@ -89,7 +89,7 @@ def _serialize_tags(self, item: dict[str, Any]) -> list[dict[str, Any]]:
8989

9090
def pytest_runtest_logreport(self, report: TestReport) -> None:
9191
try:
92-
scenario = test_report_context[report].scenario
92+
scenario = test_report_context_registry[report].scenario
9393
except KeyError:
9494
# skip reporting for non-bdd tests
9595
return
@@ -130,7 +130,7 @@ def stepmap(step: dict[str, Any]) -> dict[str, Any]:
130130
self.features[scenario["feature"]["filename"]]["elements"].append(
131131
{
132132
"keyword": scenario["keyword"],
133-
"id": test_report_context[report].name,
133+
"id": test_report_context_registry[report].name,
134134
"name": scenario["name"],
135135
"line": scenario["line_number"],
136136
"description": "",

src/pytest_bdd/gherkin_terminal_reporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from _pytest.terminal import TerminalReporter
66

7-
from .reporting import test_report_context
7+
from .reporting import test_report_context_registry
88

99
if typing.TYPE_CHECKING:
1010
from typing import Any
@@ -72,7 +72,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> Any:
7272
rule_markup = {"purple": True}
7373

7474
try:
75-
scenario = test_report_context[report].scenario
75+
scenario = test_report_context_registry[report].scenario
7676
except KeyError:
7777
scenario = None
7878

src/pytest_bdd/reporting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from .parser import Feature, Scenario, Step
2323

2424
scenario_reports_registry: WeakKeyDictionary[Item, ScenarioReport] = WeakKeyDictionary()
25-
test_report_context: WeakKeyDictionary[TestReport, ReportContext] = WeakKeyDictionary()
25+
test_report_context_registry: WeakKeyDictionary[TestReport, ReportContext] = WeakKeyDictionary()
2626

2727

2828
class StepReport:
@@ -165,7 +165,7 @@ def runtest_makereport(item: Item, call: CallInfo, rep: TestReport) -> None:
165165
except KeyError:
166166
return
167167

168-
test_report_context[rep] = ReportContext(scenario=scenario_report.serialize(), name=item.name)
168+
test_report_context_registry[rep] = ReportContext(scenario=scenario_report.serialize(), name=item.name)
169169

170170

171171
def before_scenario(request: FixtureRequest, feature: Feature, scenario: Scenario) -> None:

tests/feature/test_report.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from pytest_bdd.reporting import test_report_context
8+
from pytest_bdd.reporting import test_report_context_registry
99

1010

1111
class OfType:
@@ -105,7 +105,7 @@ def _(cucumbers, left):
105105
result = pytester.inline_run("-vvl")
106106
assert result.ret
107107
report = result.matchreport("test_passing", when="call")
108-
scenario = test_report_context[report].scenario
108+
scenario = test_report_context_registry[report].scenario
109109
expected = {
110110
"feature": {
111111
"description": "",
@@ -144,7 +144,7 @@ def _(cucumbers, left):
144144
assert scenario == expected
145145

146146
report = result.matchreport("test_failing", when="call")
147-
scenario = test_report_context[report].scenario
147+
scenario = test_report_context_registry[report].scenario
148148
expected = {
149149
"feature": {
150150
"description": "",
@@ -182,7 +182,7 @@ def _(cucumbers, left):
182182
assert scenario == expected
183183

184184
report = result.matchreport("test_outlined[12-5-7]", when="call")
185-
scenario = test_report_context[report].scenario
185+
scenario = test_report_context_registry[report].scenario
186186
expected = {
187187
"feature": {
188188
"description": "",
@@ -228,7 +228,7 @@ def _(cucumbers, left):
228228
assert scenario == expected
229229

230230
report = result.matchreport("test_outlined[5-4-1]", when="call")
231-
scenario = test_report_context[report].scenario
231+
scenario = test_report_context_registry[report].scenario
232232
expected = {
233233
"feature": {
234234
"description": "",
@@ -337,6 +337,6 @@ def test_complex(alien):
337337
report = result.matchreport("test_complex[10,20-alien0]", when="call")
338338
assert report.passed
339339

340-
report_context = test_report_context[report]
340+
report_context = test_report_context_registry[report]
341341
assert execnet.gateway_base.dumps(report_context.name)
342342
assert execnet.gateway_base.dumps(report_context.scenario)

0 commit comments

Comments
 (0)