Skip to content

Commit d3e8407

Browse files
committed
Merge branch '6.x'
2 parents c3b8cd0 + 91e9623 commit d3e8407

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Unreleased
66
- ⚠️ Backwards incompatible: - ``parsers.re`` now does a `fullmatch <https://docs.python.org/3/library/re.html#re.fullmatch>`_ instead of a partial match. This is to make it work just like the other parsers, since they don't ignore non-matching characters at the end of the string. `#539 <https://github.com/pytest-dev/pytest-bdd/pull/539>`_
77

88

9+
6.1.1
10+
-----
11+
- Fix regression introduced in version 6.1.0 where the ``pytest_bdd_after_scenario`` hook would be called after every step instead of after the scenario. `#577 <https://github.com/pytest-dev/pytest-bdd/pull/577>`_
12+
913
6.1.0
1014
-----
1115
- Fix bug where steps without parsers would take precedence over steps with parsers. `#534 <https://github.com/pytest-dev/pytest-bdd/pull/534>`_

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pytest-bdd"
3-
version = "6.1.0"
3+
version = "6.1.1"
44
description = "BDD for pytest"
55
authors = ["Oleg Pidsadnyi <[email protected]>", "Anatoly Bubenkov <[email protected]>"]
66
maintainers = ["Alessio Bogon <[email protected]>"]

tests/test_hooks.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import textwrap
22

3+
from pytest_bdd.utils import collect_dumped_objects
34

4-
def test_hooks(pytester):
5+
6+
def test_conftest_module_evaluated_twice(pytester):
7+
"""Regression test for https://github.com/pytest-dev/pytest-bdd/issues/62"""
58
pytester.makeconftest("")
69

710
subdir = pytester.mkpydir("subdir")
@@ -74,3 +77,61 @@ def test_convert_me_to_custom_item_and_assert_true():
7477

7578
result = pytester.runpytest()
7679
result.assert_outcomes(passed=1)
80+
81+
82+
def test_pytest_bdd_after_scenario_called_after_scenario(pytester):
83+
"""Regression test for https://github.com/pytest-dev/pytest-bdd/pull/577"""
84+
85+
pytester.makefile(
86+
".feature",
87+
foo=textwrap.dedent(
88+
"""\
89+
Feature: A feature
90+
Scenario: Scenario 1
91+
Given foo
92+
When bar
93+
Then baz
94+
95+
Scenario: Scenario 2
96+
When bar
97+
Then baz
98+
"""
99+
),
100+
)
101+
102+
pytester.makepyfile(
103+
"""
104+
import pytest
105+
from pytest_bdd import given, when, then, scenarios
106+
107+
108+
scenarios("foo.feature")
109+
110+
111+
@given("foo")
112+
@when("bar")
113+
@then("baz")
114+
def _():
115+
pass
116+
"""
117+
)
118+
119+
pytester.makeconftest(
120+
"""
121+
from pytest_bdd.utils import dump_obj
122+
123+
def pytest_bdd_after_scenario(request, feature, scenario):
124+
dump_obj([feature, scenario])
125+
"""
126+
)
127+
128+
result = pytester.runpytest("-s")
129+
result.assert_outcomes(passed=2)
130+
131+
hook_calls = collect_dumped_objects(result)
132+
assert len(hook_calls) == 2
133+
[(feature, scenario_1), (feature_2, scenario_2)] = hook_calls
134+
assert feature.name == feature_2.name == "A feature"
135+
136+
assert scenario_1.name == "Scenario 1"
137+
assert scenario_2.name == "Scenario 2"

0 commit comments

Comments
 (0)