21
21
from .parser import Feature , Scenario , Step
22
22
23
23
24
- # Counter to track how many times pytest initialization was started
25
- _INIT_COUNT = 0
26
-
27
-
28
24
def pytest_addhooks (pluginmanager : PytestPluginManager ) -> None :
29
25
"""Register plugin hooks."""
30
26
from pytest_bdd import hooks
@@ -56,8 +52,6 @@ def _pytest_bdd_example() -> dict:
56
52
57
53
def pytest_addoption (parser : Parser ) -> None :
58
54
"""Add pytest-bdd options."""
59
- global _INIT_COUNT
60
- _INIT_COUNT += 1
61
55
add_bdd_ini (parser )
62
56
cucumber_json .add_options (parser )
63
57
generation .add_options (parser )
@@ -72,19 +66,15 @@ def add_bdd_ini(parser: Parser) -> None:
72
66
def pytest_configure (config : Config ) -> None :
73
67
"""Configure all subplugins."""
74
68
CONFIG_STACK .append (config )
75
- assert _INIT_COUNT == len (CONFIG_STACK )
76
69
cucumber_json .configure (config )
77
70
gherkin_terminal_reporter .configure (config )
78
71
79
72
80
73
def pytest_unconfigure (config : Config ) -> None :
81
74
"""Unconfigure all subplugins."""
82
- global _INIT_COUNT
83
- assert len (CONFIG_STACK ) <= _INIT_COUNT
84
- if len (CONFIG_STACK ) == _INIT_COUNT :
75
+ if CONFIG_STACK :
85
76
CONFIG_STACK .pop ()
86
- cucumber_json .unconfigure (config )
87
- _INIT_COUNT -= 1
77
+ cucumber_json .unconfigure (config )
88
78
89
79
90
80
@pytest .hookimpl (hookwrapper = True )
0 commit comments