Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_pstats.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 6baeba54fd24 |
| children |
| rev | line source |
|---|---|
|
44833
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
1 import unittest |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
2 from test import test_support |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
3 import pstats |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
4 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
5 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
6 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
7 class AddCallersTestCase(unittest.TestCase): |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
8 """Tests for pstats.add_callers helper.""" |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
9 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
10 def test_combine_results(self): |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
11 """pstats.add_callers should combine the call results of both target |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
12 and source by adding the call time. See issue1269.""" |
|
63549
6baeba54fd24
Merged revisions 83531 via svnmerge from
Georg Brandl <georg@python.org>
parents:
44833
diff
changeset
|
13 # new format: used by the cProfile module |
|
44833
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
14 target = {"a": (1, 2, 3, 4)} |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
15 source = {"a": (1, 2, 3, 4), "b": (5, 6, 7, 8)} |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
16 new_callers = pstats.add_callers(target, source) |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
17 self.assertEqual(new_callers, {'a': (2, 4, 6, 8), 'b': (5, 6, 7, 8)}) |
|
63549
6baeba54fd24
Merged revisions 83531 via svnmerge from
Georg Brandl <georg@python.org>
parents:
44833
diff
changeset
|
18 # old format: used by the profile module |
|
6baeba54fd24
Merged revisions 83531 via svnmerge from
Georg Brandl <georg@python.org>
parents:
44833
diff
changeset
|
19 target = {"a": 1} |
|
6baeba54fd24
Merged revisions 83531 via svnmerge from
Georg Brandl <georg@python.org>
parents:
44833
diff
changeset
|
20 source = {"a": 1, "b": 5} |
|
6baeba54fd24
Merged revisions 83531 via svnmerge from
Georg Brandl <georg@python.org>
parents:
44833
diff
changeset
|
21 new_callers = pstats.add_callers(target, source) |
|
6baeba54fd24
Merged revisions 83531 via svnmerge from
Georg Brandl <georg@python.org>
parents:
44833
diff
changeset
|
22 self.assertEqual(new_callers, {'a': 2, 'b': 5}) |
|
44833
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
23 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
24 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
25 def test_main(): |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
26 test_support.run_unittest( |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
27 AddCallersTestCase |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
28 ) |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
29 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
30 |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
31 if __name__ == "__main__": |
|
89b13b693864
#1269: fix a bug in pstats.add_callers() and add a unit test file for pstats.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
32 test_main() |
