Skip to content

Commit

Permalink
Merge pull request #2483 from kyleam/bf-result-filter
Browse files Browse the repository at this point in the history
BF: cli: Don't ignore the default result_filter
  • Loading branch information
mih committed May 10, 2018
2 parents 3548325 + 7b0b8d0 commit 8bb550b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion datalad/interface/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ def call_from_parser(cls, args):
if args.common_on_failure:
kwargs['on_failure'] = args.common_on_failure
# compose filter function from to be invented cmdline options
kwargs['result_filter'] = cls._get_result_filter(args)
res_filter = cls._get_result_filter(args)
if res_filter is not None:
# Don't add result_filter if it's None because then
# eval_results can't distinguish between --report-{status,type}
# not specified via the CLI and None passed via the Python API.
kwargs['result_filter'] = res_filter
try:
ret = cls.__call__(**kwargs)
if inspect.isgenerator(ret):
Expand Down
16 changes: 16 additions & 0 deletions datalad/interface/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ def __call__(arg=None, **kwargs):
eq_(val, ["nothing is", "magical"])


def test_call_from_parser_result_filter():
class DummyOne(Interface):
@staticmethod
def __call__(**kwargs):
yield kwargs

with mock.patch.object(Interface, '_OLDSTYLE_COMMANDS', tuple()):
# call_from_parser doesn't add result_filter to the keyword arguments
# unless a CLI option sets it to a non-None value.
assert_not_in("result_filter",
DummyOne.call_from_parser(_new_args())[0])
assert_in("result_filter",
DummyOne.call_from_parser(
_new_args(common_report_type="dataset"))[0])


def test_get_result_filter_arg_vs_config():
# just tests that we would be obtaining the same constraints via
# cmdline argument or via config variable. With cmdline overloading
Expand Down

0 comments on commit 8bb550b

Please sign in to comment.