[Python-checkins] closes bpo-33445: fail properly in test_cprofile() (GH-6727)

Miss Islington (bot) webhook-mailer at python.org
Wed May 9 00:59:57 EDT 2018


https://github.com/python/cpython/commit/c925108b991b9c5f0402feb0e7f725ee3ac7da11
commit: c925108b991b9c5f0402feb0e7f725ee3ac7da11
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-05-08T21:59:50-07:00
summary:

closes bpo-33445: fail properly in test_cprofile() (GH-6727)

(cherry picked from commit ac9240b9be31d073d1b2e50ce53481ff0fc9ed23)

Co-authored-by: jdemeyer <jdemeyer at cage.ugent.be>

files:
M Lib/test/test_profile.py

diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py
index 1fc3c4266965..a9982663175a 100644
--- a/Lib/test/test_profile.py
+++ b/Lib/test/test_profile.py
@@ -51,13 +51,18 @@ def test_cprofile(self):
         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



More information about the Python-checkins mailing list