Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions gsmodutils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def test(project_path, test_id, skip_default, verbose, log_path):
click.echo('Running tests: ')
tester.progress_tests(skip_default=skip_default)
click.echo()
ts = 0
te = 0
test_successes = 0
test_errors = 0

for tf, log in tester.log.items():

Expand All @@ -127,8 +127,8 @@ def test(project_path, test_id, skip_default, verbose, log_path):
click.echo("Test file {}:".format(tf))
indicator = "Test file"
lc = log.log_count
ts += lc[0]
te += lc[1]
test_successes += lc[0]
test_errors += lc[1]
click.echo("Counted {} test assertions with {} failures".format(*lc))
# Output base test file
if not log.is_success:
Expand All @@ -147,8 +147,8 @@ def test(project_path, test_id, skip_default, verbose, log_path):
click.echo(
click.style(barstr + ' End standard output ' + barstr, fg='black', bg='white')
)
percent = round(((ts - te) / ts) * 100, 3)
click.echo('Ran {} test assertions with a total of {} errors ({}% success)'.format(ts, te, percent))
percent = round(((test_successes - test_errors) / test_successes) * 100, 3)
click.echo('Ran {} test assertions with a total of {} errors ({}% success)'.format(test_successes, test_errors, percent))

# Display errors
for tf, e in tester.load_errors:
Expand All @@ -175,6 +175,9 @@ def test(project_path, test_id, skip_default, verbose, log_path):
json.dump(tester.to_dict(), lf, indent=4)
click.echo('log file written to {}'.format(log_path))

if test_errors > 0:
exit(-1)


@click.command()
@click.argument('project_path', type=click.Path(writable=True))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_json_tests():

runner = CliRunner()
result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose'])
assert result.exit_code == 0
assert result.exit_code == -1

result = runner.invoke(gsmodutils.cli.test,
['--project_path', fp.path, '--verbose', '--test_id', 'test_x.json'])
Expand Down Expand Up @@ -154,7 +154,7 @@ def test_model(model, project, log):
runner = CliRunner()
lpath = os.path.join(fp.path, 'lp.json')
result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--log_path', lpath])
assert result.exit_code == 0
assert result.exit_code == -1

result = runner.invoke(gsmodutils.cli.test,
['--project_path', fp.path, '--verbose', '--test_id', test_codep])
Expand All @@ -164,7 +164,7 @@ def test_model(model, project, log):
['--project_path', fp.path, '--verbose',
'--test_id', '{}::test_func'.format(test_codep)])

assert result.exit_code == 0
assert result.exit_code == -1

result = runner.invoke(gsmodutils.cli.test,
['--project_path', fp.path, '--verbose', '--test_id', 'test_syn_err.py'])
Expand Down