Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
Check if we got a valid command from argparse instead of catching exc…
Browse files Browse the repository at this point in the history
…eption

- Fixes #52
  • Loading branch information
Gregg Van Hove committed Jul 31, 2018
1 parent ca047f2 commit 14c1eeb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions jasmine/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ def __init__(self, app, ci_runner):

def run(self, argv):
args = self.parser.parse_args(argv)
try:
if 'func' in args and callable(args.func):
args.func(args)
except AttributeError:
else:
self.parser.print_help()
self.parser.exit(1)

def server(self, args):
if self._check_for_config(args.config):
Expand Down
9 changes: 9 additions & 0 deletions test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,12 @@ def test_ci():

assert '2 specs, 0 failed' in str(output)
assert process.returncode == 0

def test_help_fallback():
process = Popen([sys.executable, '-c', 'from jasmine.entry_points import begin; begin()'], stdout=PIPE)
output = process.communicate()[0]
process.wait()

assert 'usage:' in str(output)
assert 'Jasmine command line' in str(output)
assert process.returncode != 0

0 comments on commit 14c1eeb

Please sign in to comment.