Rev 394: Change the bzr-builddeb test suite to use the load_tests paradigm. in http://bzr.arbash-meinel.com/branches/bzr/bzr-builddeb/use_loader
John Arbash Meinel
john at arbash-meinel.com
Thu Jan 28 11:11:48 GMT 2010
At http://bzr.arbash-meinel.com/branches/bzr/bzr-builddeb/use_loader
------------------------------------------------------------
revno: 394
revision-id: john at arbash-meinel.com-20100128111125-562zkvewykc6jzl1
parent: james.westby at canonical.com-20091218125841-o96ejvyzn30ayttr
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: use_loader
timestamp: Thu 2010-01-28 05:11:25 -0600
message:
Change the bzr-builddeb test suite to use the load_tests paradigm.
This also removes the ability to run 'python ./__init__.py' but it
probably didn't work anyway. The nice bit is that it means we can
run some of the code without having to import all of it.
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2009-08-25 20:20:10 +0000
+++ b/__init__.py 2010-01-28 11:11:25 +0000
@@ -34,7 +34,6 @@
)
commands = {
- "test_builddeb": [],
"builddeb": ["bd"],
"merge_upstream": ["mu"],
"import_dsc": [],
@@ -120,17 +119,5 @@
SPEC_TYPES.append(RevisionSpec_package)
-def test_suite():
- from unittest import TestSuite
- from bzrlib.plugins.builddeb import tests
- result = TestSuite()
- result.addTest(tests.test_suite())
- return result
-
-
-if __name__ == '__main__':
- print ("This is a Bazaar plugin. Copy this directory to ~/.bazaar/plugins "
- "to use it.\n")
- import unittest
- runner = unittest.TextTestRunner()
- runner.run(test_suite())
+def load_tests(standard_tests, module, loader):
+ return loader.loadTestsFromModuleNames(['bzrlib.plugins.builddeb.tests'])
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2009-08-19 09:56:50 +0000
+++ b/tests/__init__.py 2010-01-28 11:11:25 +0000
@@ -28,12 +28,13 @@
import os
from unittest import TestSuite
+from bzrlib.lazy_import import lazy_import
+lazy_import(globals(), """
from debian_bundle.changelog import Version, Changelog
+""")
from bzrlib.tests import TestUtil, multiply_tests, TestCaseWithTransport
-from bzrlib.plugins.builddeb.tests import blackbox
-
def make_new_upstream_dir(source, dest):
os.rename(source, dest)
@@ -109,10 +110,10 @@
return result
-def test_suite():
- loader = TestUtil.TestLoader()
- suite = TestSuite()
+def load_tests(standard_tests, module, loader):
+ suite = loader.suiteClass()
testmod_names = [
+ 'blackbox',
'test_builder',
'test_commit_message',
'test_config',
@@ -149,15 +150,9 @@
old_tarball='../package-0.2.tar')),
]
suite = multiply_tests(repack_tarball_tests, scenarios, suite)
- packages_to_test = [
- blackbox,
- ]
-
- for package in packages_to_test:
- suite.addTest(package.test_suite())
-
return suite
+
class BuilddebTestCase(TestCaseWithTransport):
package_name = 'test'
=== modified file 'tests/blackbox/__init__.py'
--- a/tests/blackbox/__init__.py 2009-08-28 16:39:39 +0000
+++ b/tests/blackbox/__init__.py 2010-01-28 11:11:25 +0000
@@ -21,7 +21,7 @@
from bzrlib.tests import TestUtil
-def test_suite():
+def load_tests(standard_tests, module, loader):
testmod_names = [
'test_builddeb',
'test_do',
@@ -30,7 +30,6 @@
'test_merge_package',
'test_merge_upstream',
]
- loader = TestUtil.TestLoader()
suite = loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i)
for i in testmod_names])
return suite
More information about the bazaar-commits
mailing list