Skip to content

Commit

Permalink
test: check if output is set
Browse files Browse the repository at this point in the history
if exception is thrown before setting the output, this will catch it.
  • Loading branch information
bkueng committed Feb 23, 2017
1 parent 5a585ee commit 43b2585
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/test_ulog2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ def run_against_file(self, expected_output_file, test):
saved_stdout = sys.stdout
with open(expected_output_file, 'r') as file_handle:
expected_output = file_handle.read().strip()
output = None
try:
out = StringIO()
sys.stdout = out
test()
output = out.getvalue().strip()
assert output == expected_output
finally:
sys.stdout = saved_stdout
print("Got output:")
print(output)
print("\nExpected output:")
print(expected_output)
if output is not None:
sys.stdout = saved_stdout
print("Got output:")
print(output)
print("\nExpected output:")
print(expected_output)

def test_ulog2csv(self):
tmpdir = tempfile.gettempdir()
Expand Down

0 comments on commit 43b2585

Please sign in to comment.