Merge pull request #641 from n3world/issue_362_unconfigure

Issue #362: Only unconfigure if configured
This commit is contained in:
Alessio Bogon 2023-11-11 20:42:07 +01:00 committed by GitHub
commit b9015198bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -72,7 +72,8 @@ def pytest_configure(config: Config) -> None:
def pytest_unconfigure(config: Config) -> None: def pytest_unconfigure(config: Config) -> None:
"""Unconfigure all subplugins.""" """Unconfigure all subplugins."""
CONFIG_STACK.pop() if CONFIG_STACK:
CONFIG_STACK.pop()
cucumber_json.unconfigure(config) cucumber_json.unconfigure(config)

View File

@ -135,3 +135,21 @@ def test_pytest_bdd_after_scenario_called_after_scenario(pytester):
assert scenario_1.name == "Scenario 1" assert scenario_1.name == "Scenario 1"
assert scenario_2.name == "Scenario 2" 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