Skip to content

Commit

Permalink
Simplify handling of func_only
Browse files Browse the repository at this point in the history
...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.
  • Loading branch information
Jmennius authored and flub committed Jul 5, 2022
1 parent 28d4d30 commit 5aff2a9
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions pytest_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def pytest_addoption(parser):
)
parser.addini("timeout", TIMEOUT_DESC)
parser.addini("timeout_method", METHOD_DESC)
parser.addini("timeout_func_only", FUNC_ONLY_DESC, type="bool")
parser.addini("timeout_func_only", FUNC_ONLY_DESC, type="bool", default=False)


class TimeoutHooks:
Expand Down Expand Up @@ -299,12 +299,7 @@ def get_env_settings(config):
method = DEFAULT_METHOD

func_only = config.getini("timeout_func_only")
if func_only == []:
# No value set
func_only = None
if func_only is not None:
func_only = _validate_func_only(func_only, "config file")
return Settings(timeout, method, func_only or False)
return Settings(timeout, method, func_only)


def _get_item_settings(item, marker=None):
Expand All @@ -323,8 +318,6 @@ def _get_item_settings(item, marker=None):
method = item.config._env_timeout_method
if func_only is None:
func_only = item.config._env_timeout_func_only
if func_only is None:
func_only = False
return Settings(timeout, method, func_only)


Expand Down

0 comments on commit 5aff2a9

Please sign in to comment.