Skip to content

Commit

Permalink
KISS in test_runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauko Quiroga committed Sep 9, 2021
1 parent 8962eef commit db4ec8c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions openfisca_core/tools/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ def run_tests(tax_benefit_system, paths, options = None):
"""

if not hasattr(paths, "__setitem__"):
paths = [paths]
argv = []

if options.get('pdb'):
argv.append('--pdb')

if not hasattr(options, "__iter__"):
options = {}
if options.get('verbose'):
argv.append('--verbose')

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

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

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

return current_tax_benefit_system


def _pytest_args(options):
"""Options we pass on to pytest if they're present."""
return ((k, v) for k, v in options.items() if k in {"pdb", "verbose"})

0 comments on commit db4ec8c

Please sign in to comment.