Merge lp:~jameinel/bzr-builddeb/use_loader into lp:bzr-builddeb

Proposed by John A Meinel
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~jameinel/bzr-builddeb/use_loader
Merge into: lp:bzr-builddeb
Diff against target: 103 lines (+10/-29)
3 files modified
__init__.py (+2/-15)
tests/__init__.py (+7/-12)
tests/blackbox/__init__.py (+1/-2)
To merge this branch: bzr merge lp:~jameinel/bzr-builddeb/use_loader
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Robert Collins (community) Approve
Review via email: mp+18188@code.launchpad.net
To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

As part of some other work I'm doing, I wanted to change the test suite to use the new "load_tests()" api. This allows you to only load a subset of the files when running the subset of the test suite. (it helps, as I can run some tests on Windows as long as I don't try to run the ones that import debian_bundle :)

Revision history for this message
Robert Collins (lifeless) wrote :

Looks good to me.

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2009-08-25 20:20:10 +0000
3+++ __init__.py 2010-01-28 11:14:14 +0000
4@@ -34,7 +34,6 @@
5 )
6
7 commands = {
8- "test_builddeb": [],
9 "builddeb": ["bd"],
10 "merge_upstream": ["mu"],
11 "import_dsc": [],
12@@ -120,17 +119,5 @@
13 SPEC_TYPES.append(RevisionSpec_package)
14
15
16-def test_suite():
17- from unittest import TestSuite
18- from bzrlib.plugins.builddeb import tests
19- result = TestSuite()
20- result.addTest(tests.test_suite())
21- return result
22-
23-
24-if __name__ == '__main__':
25- print ("This is a Bazaar plugin. Copy this directory to ~/.bazaar/plugins "
26- "to use it.\n")
27- import unittest
28- runner = unittest.TextTestRunner()
29- runner.run(test_suite())
30+def load_tests(standard_tests, module, loader):
31+ return loader.loadTestsFromModuleNames(['bzrlib.plugins.builddeb.tests'])
32
33=== modified file 'tests/__init__.py'
34--- tests/__init__.py 2009-08-19 09:56:50 +0000
35+++ tests/__init__.py 2010-01-28 11:14:14 +0000
36@@ -28,12 +28,13 @@
37 import os
38 from unittest import TestSuite
39
40+from bzrlib.lazy_import import lazy_import
41+lazy_import(globals(), """
42 from debian_bundle.changelog import Version, Changelog
43+""")
44
45 from bzrlib.tests import TestUtil, multiply_tests, TestCaseWithTransport
46
47-from bzrlib.plugins.builddeb.tests import blackbox
48-
49
50 def make_new_upstream_dir(source, dest):
51 os.rename(source, dest)
52@@ -109,10 +110,10 @@
53 return result
54
55
56-def test_suite():
57- loader = TestUtil.TestLoader()
58- suite = TestSuite()
59+def load_tests(standard_tests, module, loader):
60+ suite = loader.suiteClass()
61 testmod_names = [
62+ 'blackbox',
63 'test_builder',
64 'test_commit_message',
65 'test_config',
66@@ -149,15 +150,9 @@
67 old_tarball='../package-0.2.tar')),
68 ]
69 suite = multiply_tests(repack_tarball_tests, scenarios, suite)
70- packages_to_test = [
71- blackbox,
72- ]
73-
74- for package in packages_to_test:
75- suite.addTest(package.test_suite())
76-
77 return suite
78
79+
80 class BuilddebTestCase(TestCaseWithTransport):
81
82 package_name = 'test'
83
84=== modified file 'tests/blackbox/__init__.py'
85--- tests/blackbox/__init__.py 2009-08-28 16:39:39 +0000
86+++ tests/blackbox/__init__.py 2010-01-28 11:14:14 +0000
87@@ -21,7 +21,7 @@
88 from bzrlib.tests import TestUtil
89
90
91-def test_suite():
92+def load_tests(standard_tests, module, loader):
93 testmod_names = [
94 'test_builddeb',
95 'test_do',
96@@ -30,7 +30,6 @@
97 'test_merge_package',
98 'test_merge_upstream',
99 ]
100- loader = TestUtil.TestLoader()
101 suite = loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i)
102 for i in testmod_names])
103 return suite

Subscribers

People subscribed via source and target branches