def test_print_report(self):
hook = memory_hooks.LineProfileHook()
p = self.pool.malloc(1000)
del p
with hook:
p1 = self.pool.malloc(1000)
p2 = self.pool.malloc(2000)
del p1
del p2
io = six.StringIO()
hook.print_report(file=io)
actual = io.getvalue()
expect = r'\A_root \(3\.00KB, 2\.00KB\)'
six.assertRegex(self, actual, expect)
expect = r'.*\.py:[0-9]+:test_print_report \(1\.00KB, 0\.00B\)'
six.assertRegex(self, actual, expect)
expect = r'.*\.py:[0-9]+:test_print_report \(2\.00KB, 2\.00KB\)'
six.assertRegex(self, actual, expect)
评论列表
文章目录