]> granicus.if.org Git - python/commitdiff
closes bpo-33445: fail properly in test_cprofile() (GH-6727)
authorjdemeyer <jdemeyer@cage.ugent.be>
Wed, 9 May 2018 04:16:35 +0000 (06:16 +0200)
committerBenjamin Peterson <benjamin@python.org>
Wed, 9 May 2018 04:16:35 +0000 (21:16 -0700)
Lib/test/test_profile.py

index 1fc3c426696518f2c370b56b22293815a897f116..a9982663175a760cb14752c8c5d5110b3244acc3 100644 (file)
@@ -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