diff --git a/ocrd/ocrd/decorators/__init__.py b/ocrd/ocrd/decorators/__init__.py index 833c6c1f4..1a5d6777b 100644 --- a/ocrd/ocrd/decorators/__init__.py +++ b/ocrd/ocrd/decorators/__init__.py @@ -30,14 +30,14 @@ def ocrd_cli_wrap_processor( overwrite=False, **kwargs ): + if not sys.argv[1:]: + processorClass(workspace=None, show_help=True) + sys.exit(1) if dump_json or help or version: processorClass(workspace=None, dump_json=dump_json, show_help=help, show_version=version) sys.exit() else: LOG = getLogger('ocrd_cli_wrap_processor') - if not mets or (is_local_filename(mets) and not isfile(get_local_filename(mets))): - processorClass(workspace=None, show_help=True) - sys.exit(1) initLogging() # LOG.info('kwargs=%s' % kwargs) # Merge parameter overrides and parameters diff --git a/tests/base.py b/tests/base.py index b788764f1..3d60e1d3c 100644 --- a/tests/base.py +++ b/tests/base.py @@ -45,6 +45,7 @@ def invoke_cli(self, cli, args): """ self.capture_out_err() # XXX snapshot just before executing the CLI code = 0 + sys.argv[1:] = args # XXX necessary because sys.argv reflects pytest args not cli args try: cli.main(args=args) except SystemExit as e: diff --git a/tests/test_decorators.py b/tests/test_decorators.py index 92f4457fa..62928f9d2 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -68,7 +68,9 @@ def test_processor_no_mets(self): https://github.com/OCR-D/spec/pull/156 """ _, out_help, _ = self.invoke_cli(cli_dummy_processor, ['--help']) - exit_code, out_none, _ = self.invoke_cli(cli_dummy_processor, []) + exit_code, out_none, err = self.invoke_cli(cli_dummy_processor, []) + print("exit_code=%s\nout=%s\nerr=%s" % (exit_code, out_none, err)) + # assert 0 self.assertEqual(exit_code, 1) self.assertEqual(out_help, out_none)