summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdemeyer <jdemeyer@cage.ugent.be>2018-05-09 04:16:35 (GMT)
committerBenjamin Peterson <benjamin@python.org>2018-05-09 04:16:35 (GMT)
commitac9240b9be31d073d1b2e50ce53481ff0fc9ed23 (patch)
tree68f0a2110b47ffd0d1ef6bbc5e3c677d3d0b5d3b
parent43d12a6bd82bd09ac189069fe1eb40cdbc10a58c (diff)
downloadcpython-ac9240b9be31d073d1b2e50ce53481ff0fc9ed23.zip
cpython-ac9240b9be31d073d1b2e50ce53481ff0fc9ed23.tar.gz
cpython-ac9240b9be31d073d1b2e50ce53481ff0fc9ed23.tar.bz2
closes bpo-33445: fail properly in test_cprofile() (GH-6727)
-rw-r--r--Lib/test/test_profile.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py
index 1fc3c42..a998266 100644
--- a/Lib/test/test_profile.py
+++ b/Lib/test/test_profile.py
@@ -51,13 +51,18 @@ class ProfileTest(unittest.TestCase):
results = self.do_profiling()
expected = self.get_expected_output()
self.assertEqual(results[0], 1000)
+ fail = []
for i, method in enumerate(self.methodnames):
- if results[i+1] != expected[method]:
- print("Stats.%s output for %s doesn't fit expectation!" %
- (method, self.profilerclass.__name__))
- print('\n'.join(unified_diff(
- results[i+1].split('\n'),
- expected[method].split('\n'))))
+ a = expected[method]
+ b = results[i+1]
+ if a != b:
+ fail.append(f"\nStats.{method} output for "
+ f"{self.profilerclass.__name__} "
+ "does not fit expectation:")
+ fail.extend(unified_diff(a.split('\n'), b.split('\n'),
+ lineterm=""))
+ if fail:
+ self.fail("\n".join(fail))
def test_calling_conventions(self):
# Issue #5330: profile and cProfile wouldn't report C functions called