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

(cherry picked from commit ac9240b9be)

Co-authored-by: jdemeyer <jdemeyer@cage.ugent.be>
This commit is contained in:
Miss Islington (bot) 2018-05-08 21:38:00 -07:00 committed by GitHub
parent 3c28a6387b
commit 263523ae21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View 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