~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest.py

  • Committer: Martin Pool
  • Date: 2005-06-20 05:09:00 UTC
  • Revision ID: mbp@sourcefrog.net-20050620050900-2b5dfe7d62e4d614
- reorganize selftest code

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
 
18
import unittest
 
19
 
 
20
class _MyResult(unittest.TestResult):
 
21
#     def startTest(self, test):
 
22
#         print str(test).ljust(50),
 
23
#         unittest.TestResult.startTest(self, test)
 
24
 
 
25
#     def stopTest(self, test):
 
26
#         print
 
27
#         unittest.TestResult.stopTest(self, test)
 
28
 
 
29
 
 
30
    pass
 
31
 
 
32
 
 
33
 
18
34
def selftest():
19
 
    import unittest
20
 
    from unittest import TestLoader
21
 
    import bzrlib
22
 
    from doctest import DocTestSuite
23
 
    
24
 
    tr = unittest.TextTestRunner(verbosity=2)
25
 
    suite = unittest.TestSuite()
26
 
    import bzrlib.whitebox
27
 
 
28
 
    suite.addTest(TestLoader().loadTestsFromModule(bzrlib.whitebox))
29
 
    
30
 
    for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
31
 
            bzrlib.commands:
32
 
        suite.addTest(DocTestSuite(m))
33
 
 
34
 
    result = tr.run(suite)
35
 
    return result.wasSuccessful()
 
35
     from unittest import TestLoader, TestSuite
 
36
     import bzrlib
 
37
     import bzrlib.whitebox
 
38
     from doctest import DocTestSuite
 
39
    
 
40
     suite = TestSuite()
 
41
 
 
42
     suite.addTest(TestLoader().loadTestsFromModule(bzrlib.whitebox))
 
43
    
 
44
     for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
 
45
             bzrlib.commands:
 
46
         suite.addTest(DocTestSuite(m))
 
47
 
 
48
     result = _MyResult()
 
49
     suite.run(result)
 
50
 
 
51
     print '%4d tests run' % result.testsRun
 
52
     print '%4d errors' % len(result.errors)
 
53
     print '%4d failures' % len(result.failures)
 
54
 
 
55
     return result.wasSuccessful()
 
56