Skip to content

Commit

Permalink
Close handles when print-and-compare tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjc committed Sep 16, 2011
1 parent bba0675 commit f7ce81b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Tests/run_tests.py
Expand Up @@ -214,8 +214,10 @@ def runTest(self):
# the first line of the output file is the test name
expected_test = expected.readline().strip()

assert expected_test == self.name, "\nOutput: %s\nExpected: %s" % \
(self.name, expected_test)
if expected_test != self.name:
expected.close()
raise ValueError("\nOutput: %s\nExpected: %s" \
% (self.name, expected_test))

# now loop through the output and compare it to the expected file
while True:
Expand All @@ -239,10 +241,10 @@ def runTest(self):
if re.compile("^Ran [0-9]+ tests? in ").match(expected_line):
pass
# otherwise make sure the two lines are the same
else:
assert expected_line == output_line, \
"\nOutput : %s\nExpected: %s" \
% (repr(output_line), repr(expected_line))
elif expected_line != output_line:
expected.close()
raise ValueError("\nOutput : %s\nExpected: %s" \
% (repr(output_line), repr(expected_line)))
expected.close()

def generate_output(self):
Expand Down

0 comments on commit f7ce81b

Please sign in to comment.