]>
Commit | Line | Data |
---|---|---|
4710c53d | 1 | import unittest\r |
2 | from test import test_support\r | |
3 | import pstats\r | |
4 | \r | |
5 | \r | |
6 | \r | |
7 | class AddCallersTestCase(unittest.TestCase):\r | |
8 | """Tests for pstats.add_callers helper."""\r | |
9 | \r | |
10 | def test_combine_results(self):\r | |
11 | """pstats.add_callers should combine the call results of both target\r | |
12 | and source by adding the call time. See issue1269."""\r | |
13 | # new format: used by the cProfile module\r | |
14 | target = {"a": (1, 2, 3, 4)}\r | |
15 | source = {"a": (1, 2, 3, 4), "b": (5, 6, 7, 8)}\r | |
16 | new_callers = pstats.add_callers(target, source)\r | |
17 | self.assertEqual(new_callers, {'a': (2, 4, 6, 8), 'b': (5, 6, 7, 8)})\r | |
18 | # old format: used by the profile module\r | |
19 | target = {"a": 1}\r | |
20 | source = {"a": 1, "b": 5}\r | |
21 | new_callers = pstats.add_callers(target, source)\r | |
22 | self.assertEqual(new_callers, {'a': 2, 'b': 5})\r | |
23 | \r | |
24 | \r | |
25 | def test_main():\r | |
26 | test_support.run_unittest(\r | |
27 | AddCallersTestCase\r | |
28 | )\r | |
29 | \r | |
30 | \r | |
31 | if __name__ == "__main__":\r | |
32 | test_main()\r |