Skip to content

Commit 5aff2a9

Browse files
Jmenniusflub
authored andcommitted
Simplify handling of func_only
...by setting default on config file parsing level. pytest itself will validate that the value is a valid boolean, and if it is not set it will supply default `False` value. We later rely on this global default being always set and correct - falling back to it on test level.
1 parent 28d4d30 commit 5aff2a9

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pytest_timeout.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def pytest_addoption(parser):
7070
)
7171
parser.addini("timeout", TIMEOUT_DESC)
7272
parser.addini("timeout_method", METHOD_DESC)
73-
parser.addini("timeout_func_only", FUNC_ONLY_DESC, type="bool")
73+
parser.addini("timeout_func_only", FUNC_ONLY_DESC, type="bool", default=False)
7474

7575

7676
class TimeoutHooks:
@@ -299,12 +299,7 @@ def get_env_settings(config):
299299
method = DEFAULT_METHOD
300300

301301
func_only = config.getini("timeout_func_only")
302-
if func_only == []:
303-
# No value set
304-
func_only = None
305-
if func_only is not None:
306-
func_only = _validate_func_only(func_only, "config file")
307-
return Settings(timeout, method, func_only or False)
302+
return Settings(timeout, method, func_only)
308303

309304

310305
def _get_item_settings(item, marker=None):
@@ -323,8 +318,6 @@ def _get_item_settings(item, marker=None):
323318
method = item.config._env_timeout_method
324319
if func_only is None:
325320
func_only = item.config._env_timeout_func_only
326-
if func_only is None:
327-
func_only = False
328321
return Settings(timeout, method, func_only)
329322

330323

0 commit comments

Comments
 (0)