diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-05-30 21:41:10 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-05-30 21:41:10 (GMT) |
commit | 8e124f32442e46caab9e221d941510485b6e669a (patch) | |
tree | 76b8cecf874b10f12729e7916ab84100743879b6 /Lib/test/test_profile.py | |
parent | c06de477a35669cac037b0bc92a28f9492d76015 (diff) | |
download | cpython-8e124f32442e46caab9e221d941510485b6e669a.zip cpython-8e124f32442e46caab9e221d941510485b6e669a.tar.gz cpython-8e124f32442e46caab9e221d941510485b6e669a.tar.bz2 |
Merged revisions 73064 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73064 | antoine.pitrou | 2009-05-30 23:27:00 +0200 (sam., 30 mai 2009) | 4 lines
Issue #5330: C functions called with keyword arguments were not reported by
the various profiling modules (profile, cProfile). Patch by Hagen Fürstenau.
........
Diffstat (limited to 'Lib/test/test_profile.py')
-rwxr-xr-x | Lib/test/test_profile.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py index c972fc6..243a322 100755 --- a/Lib/test/test_profile.py +++ b/Lib/test/test_profile.py @@ -16,6 +16,7 @@ class ProfileTest(unittest.TestCase): profilerclass = profile.Profile methodnames = ['print_stats', 'print_callers', 'print_callees'] + expected_max_output = ':0(max)' def get_expected_output(self): return _ProfileOutput @@ -53,6 +54,27 @@ class ProfileTest(unittest.TestCase): results[i+1].split('\n'), expected[method].split('\n')))) + def test_calling_conventions(self): + # Issue #5330: profile and cProfile wouldn't report C functions called + # with keyword arguments. We test all calling conventions. + stmts = [ + "max([0])", + "max([0], key=int)", + "max([0], **dict(key=int))", + "max(*([0],))", + "max(*([0],), key=int)", + "max(*([0],), **dict(key=int))", + ] + for stmt in stmts: + s = StringIO() + prof = self.profilerclass(timer, 0.001) + prof.runctx(stmt, globals(), locals()) + stats = pstats.Stats(prof, stream=s) + stats.print_stats() + res = s.getvalue() + self.assertTrue(self.expected_max_output in res, + "Profiling {0!r} didn't report max:\n{1}".format(stmt, res)) + def regenerate_expected_output(filename, cls): filename = filename.rstrip('co') |