Skip to content

Commit

Permalink
Merge pull request #641 from n3world/issue_362_unconfigure
Browse files Browse the repository at this point in the history
Issue #362: Only unconfigure if configured
  • Loading branch information
youtux authored Nov 11, 2023
2 parents 5707669 + c232828 commit b901519
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pytest_bdd/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def pytest_configure(config: Config) -> None:

def pytest_unconfigure(config: Config) -> None:
"""Unconfigure all subplugins."""
CONFIG_STACK.pop()
if CONFIG_STACK:
CONFIG_STACK.pop()
cucumber_json.unconfigure(config)


Expand Down
18 changes: 18 additions & 0 deletions tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,21 @@ def pytest_bdd_after_scenario(request, feature, scenario):

assert scenario_1.name == "Scenario 1"
assert scenario_2.name == "Scenario 2"


def test_pytest_unconfigure_without_configure(pytester):
"""
Simulate a plugin forcing an exit during configuration before bdd is configured
https://github.com/pytest-dev/pytest-bdd/issues/362
"""
pytester.makeconftest(
"""
import pytest
def pytest_configure(config):
pytest.exit("Exit during configure", 0)
"""
)

result = pytester.runpytest()
assert result.ret == 0

0 comments on commit b901519

Please sign in to comment.