Skip to content

Commit ac9240b

Browse files
jdemeyerbenjaminp
authored andcommitted
closes bpo-33445: fail properly in test_cprofile() (GH-6727)
1 parent 43d12a6 commit ac9240b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Lib/test/test_profile.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,18 @@ def test_cprofile(self):
5151
results = self.do_profiling()
5252
expected = self.get_expected_output()
5353
self.assertEqual(results[0], 1000)
54+
fail = []
5455
for i, method in enumerate(self.methodnames):
55-
if results[i+1] != expected[method]:
56-
print("Stats.%s output for %s doesn't fit expectation!" %
57-
(method, self.profilerclass.__name__))
58-
print('\n'.join(unified_diff(
59-
results[i+1].split('\n'),
60-
expected[method].split('\n'))))
56+
a = expected[method]
57+
b = results[i+1]
58+
if a != b:
59+
fail.append(f"\nStats.{method} output for "
60+
f"{self.profilerclass.__name__} "
61+
"does not fit expectation:")
62+
fail.extend(unified_diff(a.split('\n'), b.split('\n'),
63+
lineterm=""))
64+
if fail:
65+
self.fail("\n".join(fail))
6166

6267
def test_calling_conventions(self):
6368
# Issue #5330: profile and cProfile wouldn't report C functions called

0 commit comments

Comments
 (0)