Skip to content

Commit c7482f3

Browse files
committed
Add language to Cucumber JSON output
1 parent b2594d6 commit c7482f3

File tree

5 files changed

+7
-0
lines changed

5 files changed

+7
-0
lines changed

src/pytest_bdd/cucumber_json.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def stepmap(step: dict[str, Any]) -> dict[str, Any]:
120120
"id": scenario["feature"]["rel_filename"].lower().replace(" ", "-"),
121121
"line": scenario["feature"]["line_number"],
122122
"description": scenario["feature"]["description"],
123+
"language": scenario["feature"]["language"],
123124
"tags": self._serialize_tags(scenario["feature"]),
124125
"elements": [],
125126
}

src/pytest_bdd/gherkin_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def from_dict(cls, data: dict[str, Any]) -> Self:
269269
@dataclass
270270
class Feature:
271271
location: Location
272+
language: str
272273
keyword: str
273274
tags: list[Tag]
274275
name: str
@@ -279,6 +280,7 @@ class Feature:
279280
def from_dict(cls, data: dict[str, Any]) -> Self:
280281
return cls(
281282
location=Location.from_dict(data["location"]),
283+
language=data["language"],
282284
keyword=data["keyword"],
283285
tags=[Tag.from_dict(tag) for tag in data["tags"]],
284286
name=data["name"],

src/pytest_bdd/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Feature:
4040
scenarios: OrderedDict[str, ScenarioTemplate]
4141
filename: str
4242
rel_filename: str
43+
language: str
4344
keyword: str
4445
name: str | None
4546
tags: set[str]
@@ -447,6 +448,7 @@ def parse(self) -> Feature:
447448
background=None,
448449
line_number=feature_data.location.line,
449450
description=textwrap.dedent(feature_data.description),
451+
language=feature_data.language,
450452
)
451453

452454
for child in feature_data.children:

src/pytest_bdd/reporting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def serialize(self) -> dict[str, Any]:
119119
"name": feature.name,
120120
"filename": feature.filename,
121121
"rel_filename": feature.rel_filename,
122+
"language": feature.language,
122123
"line_number": feature.line_number,
123124
"description": feature.description,
124125
"tags": sorted(feature.tags),

tests/feature/test_cucumber_json.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def test_passing_outline():
225225
],
226226
"id": os.path.join("test_step_trace0", "test.feature"),
227227
"keyword": "Feature",
228+
"language": "en",
228229
"line": 2,
229230
"name": "One passing scenario, one failing scenario",
230231
"tags": [{"name": "feature-tag", "line": 1}],

0 commit comments

Comments
 (0)