Skip to content

Commit

Permalink
Add trap for null subparser
Browse files Browse the repository at this point in the history
Also update corresponding test to match the actual error message.

Closes #239
  • Loading branch information
bskinn committed Jun 4, 2022
1 parent 2f258b9 commit 749b9c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/sphobjinv/cli/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ def main():
print(PrsConst.VER_TXT)
sys.exit(0)

# At this point, need to trap for a null subparser
if not params[PrsConst.SUBPARSER_NAME]:
prs.error("No subparser selected")

# Regardless of mode, insert extra blank line
# for cosmetics
log_print(" ", params)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_cli_no_subparser_prs_exit(self, run_cmdline_test):
with stdio_mgr() as (in_, out_, err_):
run_cmdline_test(["--foo"], expect=2)

assert "required: {convert,suggest}" in err_.getvalue()
assert "error: No subparser selected" in err_.getvalue()

@pytest.mark.timeout(CLI_TEST_TIMEOUT)
def test_cli_bad_subparser_prs_exit(self, run_cmdline_test):
Expand Down

0 comments on commit 749b9c9

Please sign in to comment.