~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lsprof.py

  • Committer: Aaron Bentley
  • Date: 2007-06-12 14:13:50 UTC
  • mto: This revision was merged to the branch mainline in revision 2527.
  • Revision ID: abentley@panoramicfeedback.com-20070612141350-nk6niovgz6ne2vit
Make LSProf into a Feature required by the appropriate tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
 
23
23
import bzrlib
24
 
from bzrlib.lsprof import profile
25
 
from bzrlib.tests import TestCaseInTempDir
 
24
from bzrlib import tests
 
25
 
 
26
 
 
27
class LSProf(tests.Feature):
 
28
 
 
29
    def available(self):
 
30
        try:
 
31
            from bzrlib import lsprof
 
32
        except ImportError:
 
33
            return False
 
34
        else:
 
35
            return True
26
36
 
27
37
 
28
38
_TXT_HEADER = "   CallCount    Recursive    Total(ms)   " + \
36
46
 
37
47
def _collect_stats():
38
48
    "Collect and return some dummy profile data."
 
49
    from bzrlib.lsprof import profile
39
50
    ret, stats = profile(_junk_callable)
40
51
    return stats
41
52
 
42
53
 
43
 
class TestStatsSave(TestCaseInTempDir):
 
54
class TestStatsSave(tests.TestCaseInTempDir):
44
55
 
45
56
    def setUp(self):
46
 
        super(TestCaseInTempDir, self).setUp()
 
57
        super(tests.TestCaseInTempDir, self).setUp()
 
58
        self.requireFeature(LSProf())
47
59
        self.stats = _collect_stats()
48
60
 
49
61
    def _tempfile(self, ext):