~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lsprof.py

  • Committer: Ian Clatworthy
  • Date: 2007-06-06 11:51:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2527.
  • Revision ID: ian.clatworthy@internode.on.net-20070606115137-iq6sk13d8p356bo8
explicit format saving test

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from bzrlib.tests import TestCaseInTempDir
26
26
 
27
27
 
 
28
_TXT_HEADER = "   CallCount    Recursive    Total(ms)   " + \
 
29
    "Inline(ms) module:lineno(function)\n"
 
30
 
 
31
 
28
32
def _junk_callable():
29
33
    "A simple routine to profile."
30
34
    result = sorted(['abc', 'def', 'ghi'])
50
54
        f = self._tempfile("txt")
51
55
        self.stats.save(f)
52
56
        lines = open(f).readlines()
53
 
        self.assertEqual(lines[0], "   CallCount    Recursive    Total(ms)   "
54
 
            "Inline(ms) module:lineno(function)\n")
 
57
        self.assertEqual(lines[0], _TXT_HEADER)
55
58
 
56
59
    def test_stats_save_to_callgrind(self):
57
60
        f = self._tempfile("callgrind")
58
61
        self.stats.save(f)
59
62
        lines = open(f).readlines()
 
63
        self.assertEqual(lines[0], "events: Ticks\n")
 
64
        # Test explicit format nommination
 
65
        f2 = self._tempfile("txt")
 
66
        self.stats.save(f2, format="callgrind")
 
67
        lines2 = open(f2).readlines()
 
68
        self.assertEqual(lines2[0], "events: Ticks\n")
60
69
 
61
70
    def test_stats_save_to_pickle(self):
62
71
        f = self._tempfile("pkl")