Skip to content

Commit 5e2c70d

Browse files
author
Mauko Quiroga
committed
KISS in test_runner
1 parent d41188a commit 5e2c70d

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

openfisca_core/tools/test_runner.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ def run_tests(tax_benefit_system, paths, options = None):
6464
6565
"""
6666

67-
if not hasattr(paths, "__setitem__"):
68-
paths = [paths]
67+
argv = []
68+
69+
if options.get('pdb'):
70+
argv.append('--pdb')
6971

70-
if not hasattr(options, "__iter__"):
71-
options = {}
72+
if options.get('verbose'):
73+
argv.append('--verbose')
7274

73-
#: Check whether pytest args were passed to ``openfisca test``.
74-
argv = [f"--{arg}" for arg, flag in _pytest_args(options) if flag is True]
75+
if isinstance(paths, str):
76+
paths = [paths]
7577

7678
return pytest.main([*argv, *paths] if True else paths, plugins = [OpenFiscaPlugin(tax_benefit_system, options)])
7779

@@ -283,8 +285,3 @@ def _get_tax_benefit_system(baseline, reforms, extensions):
283285
_tax_benefit_system_cache[key] = current_tax_benefit_system
284286

285287
return current_tax_benefit_system
286-
287-
288-
def _pytest_args(options):
289-
"""Options we pass on to pytest if they're present."""
290-
return ((k, v) for k, v in options.items() if k in {"pdb", "verbose"})

0 commit comments

Comments
 (0)