Skip to content

Commit

Permalink
Fix list-modules error when there are no traces (#90) (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrinwu authored and carljm committed Aug 19, 2018
1 parent a5c0279 commit 0bb4c0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 0 additions & 3 deletions monkeytype/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ def print_stub_handler(args: argparse.Namespace, stdout: IO, stderr: IO) -> None
def list_modules_handler(args: argparse.Namespace, stdout: IO, stderr: IO) -> None:
output, file = None, stdout
modules = args.config.trace_store().list_modules()
if not modules:
complain_about_no_traces(args, stderr)
return
output = '\n'.join(modules)
print(output, file=file)

Expand Down
11 changes: 11 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ def test_display_list_of_modules(store_data, stdout, stderr):
assert ret == 0


def test_display_list_of_modules_no_modules(store_data, stdout, stderr):
store, db_file = store_data
with mock.patch.dict(os.environ, {DefaultConfig.DB_PATH_VAR: db_file.name}):
ret = cli.main(['list-modules'], stdout, stderr)
expected = ""
assert stderr.getvalue() == expected
expected = "\n"
assert stdout.getvalue() == expected
assert ret == 0


def test_display_sample_count(capsys, stderr):
traces = [
CallTrace(func, {'a': int, 'b': str}, NoneType),
Expand Down

0 comments on commit 0bb4c0a

Please sign in to comment.