[Pkg-bazaar-commits] ./bzr/unstable r608: - Split selftests out into a new module and start changing them
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:20:16 UTC 2009
------------------------------------------------------------
revno: 608
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-05-31 17:42:44 +1000
message:
- Split selftests out into a new module and start changing them
to use the unittest module
added:
bzrlib/selftest.py
modified:
bzrlib/commands.py
bzrlib/whitebox.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-05-31 03:02:45 +0000
+++ b/bzrlib/commands.py 2005-05-31 07:42:44 +0000
@@ -930,29 +930,11 @@
"""Run internal test suite"""
hidden = True
def run(self):
- failures, tests = 0, 0
-
- import doctest, bzrlib.store
- bzrlib.trace.verbose = False
-
- for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
- bzrlib.tree, bzrlib.commands, bzrlib.add:
- mf, mt = doctest.testmod(m)
- failures += mf
- tests += mt
- print '%-40s %3d tests' % (m.__name__, mt),
- if mf:
- print '%3d FAILED!' % mf
- else:
- print
-
- print '%-40s %3d tests' % ('total', tests),
- if failures:
- print '%3d FAILED!' % failures
+ from bzrlib.selftest import selftest
+ if selftest():
+ return 0
+ else:
return 1
- else:
- print
- return 0
=== added file 'bzrlib/selftest.py'
--- a/bzrlib/selftest.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/selftest.py 2005-05-31 07:42:44 +0000
@@ -0,0 +1,34 @@
+# Copyright (C) 2005 by Canonical Ltd
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+def selftest():
+ import unittest
+ from unittest import TestLoader
+ import bzrlib
+ from doctest import DocTestSuite
+
+ tr = unittest.TextTestRunner(verbosity=2)
+ suite = unittest.TestSuite()
+ import bzrlib.whitebox
+
+ suite.addTest(TestLoader().loadTestsFromModule(bzrlib.whitebox))
+
+ for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
+ bzrlib.tree, bzrlib.commands, bzrlib.add:
+ suite.addTest(DocTestSuite(m))
+
+ result = tr.run(suite)
+ return result.wasSuccessful()
=== modified file 'bzrlib/whitebox.py'
--- a/bzrlib/whitebox.py 2005-05-30 06:47:35 +0000
+++ b/bzrlib/whitebox.py 2005-05-31 07:42:44 +0000
@@ -71,7 +71,6 @@
os.chdir(savedir)
shutil.rmtree(dtmp)
-
if __name__ == '__main__':
unittest.main()
More information about the Pkg-bazaar-commits
mailing list