2
from test import support
3
from io import StringIO
8
class AddCallersTestCase(unittest.TestCase):
9
"""Tests for pstats.add_callers helper."""
11
def test_combine_results(self):
12
# pstats.add_callers should combine the call results of both target
13
# and source by adding the call time. See issue1269.
14
# new format: used by the cProfile module
15
target = {"a": (1, 2, 3, 4)}
16
source = {"a": (1, 2, 3, 4), "b": (5, 6, 7, 8)}
17
new_callers = pstats.add_callers(target, source)
18
self.assertEqual(new_callers, {'a': (2, 4, 6, 8), 'b': (5, 6, 7, 8)})
19
# old format: used by the profile module
21
source = {"a": 1, "b": 5}
22
new_callers = pstats.add_callers(target, source)
23
self.assertEqual(new_callers, {'a': 2, 'b': 5})
26
class StatsTestCase(unittest.TestCase):
28
stats_file = support.findfile('pstats.pck')
29
self.stats = pstats.Stats(stats_file)
33
stats = pstats.Stats(stream=stream)
34
stats.add(self.stats, self.stats)
44
if __name__ == "__main__":