15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
# TODO: Perhaps there should be an API to find out if bzr running under the
19
# test suite -- some plugins might want to avoid making intrusive changes if
20
# this is the case. However, we want behaviour under to test to diverge as
21
# little as possible, so this should be used rarely if it's added at all.
22
# (Suggestion from j-a-meinel, 2005-11-24)
24
from cStringIO import StringIO
28
39
import bzrlib.commands
40
from bzrlib.errors import BzrError
41
import bzrlib.inventory
44
import bzrlib.osutils as osutils
30
47
import bzrlib.trace
48
from bzrlib.transport import urlescape
49
from bzrlib.trace import mutter
50
from bzrlib.tests.TestUtil import TestLoader, TestSuite
51
from bzrlib.tests.treeshape import build_tree_contents
34
53
MODULES_TO_TEST = []
35
MODULES_TO_DOCTEST = []
37
from logging import debug, warning, error
54
MODULES_TO_DOCTEST = [
64
def packages_to_test():
65
import bzrlib.tests.blackbox
71
class EarlyStoppingTestResultAdapter(object):
72
"""An adapter for TestResult to stop at the first first failure or error"""
74
def __init__(self, result):
77
def addError(self, test, err):
78
self._result.addError(test, err)
81
def addFailure(self, test, err):
82
self._result.addFailure(test, err)
85
def __getattr__(self, name):
86
return getattr(self._result, name)
88
def __setattr__(self, name, value):
90
object.__setattr__(self, name, value)
91
return setattr(self._result, name, value)
94
class _MyResult(unittest._TextTestResult):
97
Shows output in a different format, including displaying runtime for tests.
100
def _elapsedTime(self):
101
return "%5dms" % (1000 * (time.time() - self._start_time))
103
def startTest(self, test):
104
unittest.TestResult.startTest(self, test)
105
# In a short description, the important words are in
106
# the beginning, but in an id, the important words are
108
SHOW_DESCRIPTIONS = False
110
width = osutils.terminal_width()
111
name_width = width - 15
113
if SHOW_DESCRIPTIONS:
114
what = test.shortDescription()
116
if len(what) > name_width:
117
what = what[:name_width-3] + '...'
120
if what.startswith('bzrlib.tests.'):
122
if len(what) > name_width:
123
what = '...' + what[3-name_width:]
124
what = what.ljust(name_width)
125
self.stream.write(what)
127
self._start_time = time.time()
129
def addError(self, test, err):
130
if isinstance(err[1], TestSkipped):
131
return self.addSkipped(test, err)
132
unittest.TestResult.addError(self, test, err)
134
self.stream.writeln("ERROR %s" % self._elapsedTime())
136
self.stream.write('E')
139
def addFailure(self, test, err):
140
unittest.TestResult.addFailure(self, test, err)
142
self.stream.writeln(" FAIL %s" % self._elapsedTime())
144
self.stream.write('F')
147
def addSuccess(self, test):
149
self.stream.writeln(' OK %s' % self._elapsedTime())
151
self.stream.write('~')
153
unittest.TestResult.addSuccess(self, test)
155
def addSkipped(self, test, skip_excinfo):
157
print >>self.stream, ' SKIP %s' % self._elapsedTime()
158
print >>self.stream, ' %s' % skip_excinfo[1]
160
self.stream.write('S')
162
# seems best to treat this as success from point-of-view of unittest
163
# -- it actually does nothing so it barely matters :)
164
unittest.TestResult.addSuccess(self, test)
166
def printErrorList(self, flavour, errors):
167
for test, err in errors:
168
self.stream.writeln(self.separator1)
169
self.stream.writeln("%s: %s" % (flavour, self.getDescription(test)))
170
if hasattr(test, '_get_log'):
172
print >>self.stream, \
173
('vvvv[log from %s]' % test.id()).ljust(78,'-')
174
print >>self.stream, test._get_log()
175
print >>self.stream, \
176
('^^^^[log from %s]' % test.id()).ljust(78,'-')
177
self.stream.writeln(self.separator2)
178
self.stream.writeln("%s" % err)
181
class TextTestRunner(unittest.TextTestRunner):
182
stop_on_failure = False
184
def _makeResult(self):
185
result = _MyResult(self.stream, self.descriptions, self.verbosity)
186
if self.stop_on_failure:
187
result = EarlyStoppingTestResultAdapter(result)
191
def iter_suite_tests(suite):
192
"""Return all tests in a suite, recursing through nested suites"""
193
for item in suite._tests:
194
if isinstance(item, unittest.TestCase):
196
elif isinstance(item, unittest.TestSuite):
197
for r in iter_suite_tests(item):
200
raise Exception('unknown object %r inside test suite %r'
204
class TestSkipped(Exception):
205
"""Indicates that a test was intentionally skipped, rather than failing."""
39
209
class CommandFailed(Exception):
48
218
Error and debug log messages are redirected from their usual
49
219
location into a temporary file, the contents of which can be
50
retrieved by _get_log().
220
retrieved by _get_log(). We use a real OS file, not an in-memory object,
221
so that it can also capture file IO. When the test completes this file
222
is read into memory and removed from disk.
52
224
There are also convenience functions to invoke bzr's command-line
53
routine, and to build and check bzr trees."""
225
routine, and to build and check bzr trees.
227
In addition to the usual method of overriding tearDown(), this class also
228
allows subclasses to register functions into the _cleanups list, which is
229
run in order as the object is torn down. It's less likely this will be
230
accidentally overlooked.
234
_log_file_name = None
58
# this replaces the default testsweet.TestCase; we don't want logging changed
59
238
unittest.TestCase.setUp(self)
240
self._cleanEnvironment()
60
241
bzrlib.trace.disable_default_logging()
61
self._enable_file_logging()
64
def _enable_file_logging(self):
244
def _ndiff_strings(self, a, b):
245
"""Return ndiff between two strings containing lines.
247
A trailing newline is added if missing to make the strings
249
if b and b[-1] != '\n':
251
if a and a[-1] != '\n':
253
difflines = difflib.ndiff(a.splitlines(True),
255
linejunk=lambda x: False,
256
charjunk=lambda x: False)
257
return ''.join(difflines)
259
def assertEqualDiff(self, a, b):
260
"""Assert two texts are equal, if not raise an exception.
262
This is intended for use with multi-line strings where it can
263
be hard to find the differences by eye.
265
# TODO: perhaps override assertEquals to call this for strings?
268
raise AssertionError("texts not equal:\n" +
269
self._ndiff_strings(a, b))
271
def assertStartsWith(self, s, prefix):
272
if not s.startswith(prefix):
273
raise AssertionError('string %r does not start with %r' % (s, prefix))
275
def assertEndsWith(self, s, suffix):
276
if not s.endswith(prefix):
277
raise AssertionError('string %r does not end with %r' % (s, suffix))
279
def assertContainsRe(self, haystack, needle_re):
280
"""Assert that a contains something matching a regular expression."""
281
if not re.search(needle_re, haystack):
282
raise AssertionError('pattern "%s" not found in "%s"'
283
% (needle_re, haystack))
285
def AssertSubset(self, sublist, superlist):
286
"""Assert that every entry in sublist is present in superlist."""
288
for entry in sublist:
289
if entry not in superlist:
290
missing.append(entry)
292
raise AssertionError("value(s) %r not present in container %r" %
293
(missing, superlist))
295
def assertTransportMode(self, transport, path, mode):
296
"""Fail if a path does not have mode mode.
298
If modes are not supported on this platform, the test is skipped.
300
if sys.platform == 'win32':
302
path_stat = transport.stat(path)
303
actual_mode = stat.S_IMODE(path_stat.st_mode)
304
self.assertEqual(mode, actual_mode,
305
'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
307
def _startLogFile(self):
308
"""Send bzr and test log messages to a temporary file.
310
The file is removed as the test is torn down.
65
312
fileno, name = tempfile.mkstemp(suffix='.log', prefix='testbzr')
67
self._log_file = os.fdopen(fileno, 'w+')
69
hdlr = logging.StreamHandler(self._log_file)
70
hdlr.setLevel(logging.DEBUG)
71
hdlr.setFormatter(logging.Formatter('%(levelname)8s %(message)s'))
72
logging.getLogger('').addHandler(hdlr)
73
logging.getLogger('').setLevel(logging.DEBUG)
75
debug('opened log file %s', name)
313
encoder, decoder, stream_reader, stream_writer = codecs.lookup('UTF-8')
314
self._log_file = stream_writer(os.fdopen(fileno, 'w+'))
315
bzrlib.trace.enable_test_log(self._log_file)
77
316
self._log_file_name = name
81
logging.getLogger('').removeHandler(self._log_hdlr)
82
bzrlib.trace.enable_default_logging()
83
logging.debug('%s teardown', self.id())
317
self.addCleanup(self._finishLogFile)
319
def _finishLogFile(self):
320
"""Finished with the log file.
322
Read contents into memory, close, and delete.
324
bzrlib.trace.disable_test_log()
325
self._log_file.seek(0)
326
self._log_contents = self._log_file.read()
84
327
self._log_file.close()
328
os.remove(self._log_file_name)
329
self._log_file = self._log_file_name = None
331
def addCleanup(self, callable):
332
"""Arrange to run a callable when this case is torn down.
334
Callables are run in the reverse of the order they are registered,
335
ie last-in first-out.
337
if callable in self._cleanups:
338
raise ValueError("cleanup function %r already registered on %s"
340
self._cleanups.append(callable)
342
def _cleanEnvironment(self):
345
'APPDATA': os.getcwd(),
350
self.addCleanup(self._restoreEnvironment)
351
for name, value in new_env.iteritems():
352
self._captureVar(name, value)
355
def _captureVar(self, name, newvalue):
356
"""Set an environment variable, preparing it to be reset when finished."""
357
self.__old_env[name] = os.environ.get(name, None)
359
if name in os.environ:
362
os.environ[name] = newvalue
365
def _restoreVar(name, value):
367
if name in os.environ:
370
os.environ[name] = value
372
def _restoreEnvironment(self):
373
for name, value in self.__old_env.iteritems():
374
self._restoreVar(name, value)
85
378
unittest.TestCase.tearDown(self)
380
def _runCleanups(self):
381
"""Run registered cleanup functions.
383
This should only be called from TestCase.tearDown.
385
# TODO: Perhaps this should keep running cleanups even if
387
for cleanup_fn in reversed(self._cleanups):
88
390
def log(self, *args):
91
393
def _get_log(self):
92
394
"""Return as a string the log for this test"""
93
return open(self._log_file_name).read()
395
if self._log_file_name:
396
return open(self._log_file_name).read()
398
return self._log_contents
399
# TODO: Delete the log after it's been read in
401
def capture(self, cmd, retcode=0):
402
"""Shortcut that splits cmd into words, runs, and returns stdout"""
403
return self.run_bzr_captured(cmd.split(), retcode=retcode)[0]
405
def run_bzr_captured(self, argv, retcode=0):
406
"""Invoke bzr and return (stdout, stderr).
408
Useful for code that wants to check the contents of the
409
output, the way error messages are presented, etc.
411
This should be the main method for tests that want to exercise the
412
overall behavior of the bzr application (rather than a unit test
413
or a functional test of the library.)
415
Much of the old code runs bzr by forking a new copy of Python, but
416
that is slower, harder to debug, and generally not necessary.
418
This runs bzr through the interface that catches and reports
419
errors, and with logging set to something approximating the
420
default, so that error reporting can be checked.
422
argv -- arguments to invoke bzr
423
retcode -- expected return code, or None for don't-care.
427
self.log('run bzr: %s', ' '.join(argv))
428
# FIXME: don't call into logging here
429
handler = logging.StreamHandler(stderr)
430
handler.setFormatter(bzrlib.trace.QuietFormatter())
431
handler.setLevel(logging.INFO)
432
logger = logging.getLogger('')
433
logger.addHandler(handler)
435
result = self.apply_redirected(None, stdout, stderr,
436
bzrlib.commands.run_bzr_catch_errors,
439
logger.removeHandler(handler)
440
out = stdout.getvalue()
441
err = stderr.getvalue()
443
self.log('output:\n%s', out)
445
self.log('errors:\n%s', err)
446
if retcode is not None:
447
self.assertEquals(result, retcode)
95
450
def run_bzr(self, *args, **kwargs):
96
451
"""Invoke bzr, as if it were run from the command line.
202
558
# successfully created
203
TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
559
TestCaseInTempDir.TEST_ROOT = osutils.abspath(root)
205
561
# make a fake bzr directory there to prevent any tests propagating
206
562
# up onto the source directory's real branch
207
os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
563
os.mkdir(osutils.pathjoin(TestCaseInTempDir.TEST_ROOT, '.bzr'))
210
566
super(TestCaseInTempDir, self).setUp()
212
567
self._make_test_root()
213
self._currentdir = os.getcwdu()
214
short_id = self.id().replace('bzrlib.selftest.', '') \
568
_currentdir = os.getcwdu()
569
short_id = self.id().replace('bzrlib.tests.', '') \
215
570
.replace('__main__.', '')
216
self.test_dir = os.path.join(self.TEST_ROOT, short_id)
571
self.test_dir = osutils.pathjoin(self.TEST_ROOT, short_id)
217
572
os.mkdir(self.test_dir)
218
573
os.chdir(self.test_dir)
574
os.environ['HOME'] = self.test_dir
575
os.environ['APPDATA'] = self.test_dir
576
def _leaveDirectory():
577
os.chdir(_currentdir)
578
self.addCleanup(_leaveDirectory)
222
os.chdir(self._currentdir)
223
super(TestCaseInTempDir, self).tearDown()
225
def _formcmd(self, cmd):
226
if isinstance(cmd, basestring):
229
cmd[0] = self.BZRPATH
230
if self.OVERRIDE_PYTHON:
231
cmd.insert(0, self.OVERRIDE_PYTHON)
232
self.log('$ %r' % cmd)
235
def runcmd(self, cmd, retcode=0):
236
"""Run one command and check the return code.
238
Returns a tuple of (stdout,stderr) strings.
240
If a single string is based, it is split into words.
241
For commands that are not simple space-separated words, please
242
pass a list instead."""
243
cmd = self._formcmd(cmd)
244
self.log('$ ' + ' '.join(cmd))
245
actual_retcode = subprocess.call(cmd, stdout=self._log_file,
246
stderr=self._log_file)
247
if retcode != actual_retcode:
248
raise CommandFailed("test failed: %r returned %d, expected %d"
249
% (cmd, actual_retcode, retcode))
251
def backtick(self, cmd, retcode=0):
252
"""Run a command and return its output"""
253
cmd = self._formcmd(cmd)
254
child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=self._log_file)
255
outd, errd = child.communicate()
257
actual_retcode = child.wait()
259
outd = outd.replace('\r', '')
261
if retcode != actual_retcode:
262
raise CommandFailed("test failed: %r returned %d, expected %d"
263
% (cmd, actual_retcode, retcode))
269
def build_tree(self, shape):
580
def build_tree(self, shape, line_endings='native', transport=None):
270
581
"""Build a test tree according to a pattern.
272
583
shape is a sequence of file specifications. If the final
273
584
character is '/', a directory is created.
275
586
This doesn't add anything to a branch.
587
:param line_endings: Either 'binary' or 'native'
588
in binary mode, exact contents are written
589
in native mode, the line endings match the
590
default platform endings.
592
:param transport: A transport to write to, for building trees on
593
VFS's. If the transport is readonly or None,
594
"." is opened automatically.
277
596
# XXX: It's OK to just create them using forward slashes on windows?
597
if transport is None or transport.is_readonly():
598
transport = bzrlib.transport.get_transport(".")
279
599
for name in shape:
280
assert isinstance(name, basestring)
600
self.assert_(isinstance(name, basestring))
281
601
if name[-1] == '/':
602
transport.mkdir(urlescape(name[:-1]))
285
print >>f, "contents of", name
290
class MetaTestLog(TestCase):
291
def test_logging(self):
292
"""Test logs are captured when a test fails."""
293
logging.info('an info message')
294
warning('something looks dodgy...')
295
logging.debug('hello, test is running')
299
def selftest(verbose=False, pattern=".*"):
604
if line_endings == 'binary':
606
elif line_endings == 'native':
609
raise BzrError('Invalid line ending request %r' % (line_endings,))
610
content = "contents of %s%s" % (name, end)
611
transport.put(urlescape(name), StringIO(content))
613
def build_tree_contents(self, shape):
614
build_tree_contents(shape)
616
def failUnlessExists(self, path):
617
"""Fail unless path, which may be abs or relative, exists."""
618
self.failUnless(osutils.lexists(path))
620
def failIfExists(self, path):
621
"""Fail if path, which may be abs or relative, exists."""
622
self.failIf(osutils.lexists(path))
624
def assertFileEqual(self, content, path):
625
"""Fail if path does not contain 'content'."""
626
self.failUnless(osutils.lexists(path))
627
self.assertEqualDiff(content, open(path, 'r').read())
630
def filter_suite_by_re(suite, pattern):
632
filter_re = re.compile(pattern)
633
for test in iter_suite_tests(suite):
634
if filter_re.search(test.id()):
639
def run_suite(suite, name='test', verbose=False, pattern=".*",
640
stop_on_failure=False, keep_output=False):
641
TestCaseInTempDir._TEST_NAME = name
646
runner = TextTestRunner(stream=sys.stdout,
649
runner.stop_on_failure=stop_on_failure
651
suite = filter_suite_by_re(suite, pattern)
652
result = runner.run(suite)
653
# This is still a little bogus,
654
# but only a little. Folk not using our testrunner will
655
# have to delete their temp directories themselves.
656
if result.wasSuccessful() or not keep_output:
657
if TestCaseInTempDir.TEST_ROOT is not None:
658
shutil.rmtree(TestCaseInTempDir.TEST_ROOT)
660
print "Failed tests working directories are in '%s'\n" % TestCaseInTempDir.TEST_ROOT
661
return result.wasSuccessful()
664
def selftest(verbose=False, pattern=".*", stop_on_failure=True,
300
666
"""Run the whole test suite under the enhanced runner"""
301
return testsweet.run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
667
return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern,
668
stop_on_failure=stop_on_failure, keep_output=keep_output)
304
671
def test_suite():
305
672
"""Build and return TestSuite for the whole program."""
306
from bzrlib.selftest.TestUtil import TestLoader, TestSuite
307
import bzrlib, bzrlib.store, bzrlib.inventory, bzrlib.branch
308
import bzrlib.osutils, bzrlib.commands, bzrlib.merge3, bzrlib.plugin
309
673
from doctest import DocTestSuite
315
global MODULES_TO_TEST, MODULES_TO_DOCTEST
318
['bzrlib.selftest.MetaTestLog',
319
'bzrlib.selftest.testinv',
320
'bzrlib.selftest.versioning',
321
'bzrlib.selftest.testmerge3',
322
'bzrlib.selftest.testhashcache',
323
'bzrlib.selftest.teststatus',
324
'bzrlib.selftest.testlog',
325
'bzrlib.selftest.testrevisionnamespaces',
326
'bzrlib.selftest.testbranch',
327
# 'bzrlib.selftest.testrevision',
328
# 'bzrlib.selftest.test_merge_core',
329
'bzrlib.selftest.test_smart_add',
330
'bzrlib.selftest.testdiff',
331
# 'bzrlib.selftest.test_parent',
332
'bzrlib.selftest.test_xml',
333
'bzrlib.selftest.test_weave',
334
# 'bzrlib.selftest.testfetch',
335
# 'bzrlib.selftest.whitebox',
336
'bzrlib.selftest.teststore',
337
# 'bzrlib.selftest.blackbox',
675
global MODULES_TO_DOCTEST
678
'bzrlib.tests.test_ancestry',
679
'bzrlib.tests.test_annotate',
680
'bzrlib.tests.test_api',
681
'bzrlib.tests.test_bad_files',
682
'bzrlib.tests.test_basis_inventory',
683
'bzrlib.tests.test_branch',
684
'bzrlib.tests.test_command',
685
'bzrlib.tests.test_commit',
686
'bzrlib.tests.test_commit_merge',
687
'bzrlib.tests.test_config',
688
'bzrlib.tests.test_conflicts',
689
'bzrlib.tests.test_diff',
690
'bzrlib.tests.test_fetch',
691
'bzrlib.tests.test_fileid_involved',
692
'bzrlib.tests.test_gpg',
693
'bzrlib.tests.test_graph',
694
'bzrlib.tests.test_hashcache',
695
'bzrlib.tests.test_http',
696
'bzrlib.tests.test_identitymap',
697
'bzrlib.tests.test_inv',
698
'bzrlib.tests.test_log',
699
'bzrlib.tests.test_merge',
700
'bzrlib.tests.test_merge3',
701
'bzrlib.tests.test_merge_core',
702
'bzrlib.tests.test_missing',
703
'bzrlib.tests.test_msgeditor',
704
'bzrlib.tests.test_nonascii',
705
'bzrlib.tests.test_options',
706
'bzrlib.tests.test_osutils',
707
'bzrlib.tests.test_parent',
708
'bzrlib.tests.test_permissions',
709
'bzrlib.tests.test_plugins',
710
'bzrlib.tests.test_remove',
711
'bzrlib.tests.test_revision',
712
'bzrlib.tests.test_revisionnamespaces',
713
'bzrlib.tests.test_revprops',
714
'bzrlib.tests.test_reweave',
715
'bzrlib.tests.test_rio',
716
'bzrlib.tests.test_sampler',
717
'bzrlib.tests.test_selftest',
718
'bzrlib.tests.test_setup',
719
'bzrlib.tests.test_sftp_transport',
720
'bzrlib.tests.test_smart_add',
721
'bzrlib.tests.test_source',
722
'bzrlib.tests.test_status',
723
'bzrlib.tests.test_store',
724
'bzrlib.tests.test_symbol_versioning',
725
'bzrlib.tests.test_testament',
726
'bzrlib.tests.test_trace',
727
'bzrlib.tests.test_transactions',
728
'bzrlib.tests.test_transport',
729
'bzrlib.tests.test_tsort',
730
'bzrlib.tests.test_ui',
731
'bzrlib.tests.test_uncommit',
732
'bzrlib.tests.test_upgrade',
733
'bzrlib.tests.test_weave',
734
'bzrlib.tests.test_whitebox',
735
'bzrlib.tests.test_workingtree',
736
'bzrlib.tests.test_xml',
340
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,
341
bzrlib.osutils, bzrlib.commands, bzrlib.merge3):
342
if m not in MODULES_TO_DOCTEST:
343
MODULES_TO_DOCTEST.append(m)
345
TestCase.BZRPATH = os.path.join(os.path.realpath(os.path.dirname(bzrlib.__path__[0])), 'bzr')
346
print '%-30s %s' % ('bzr binary', TestCase.BZRPATH)
738
test_transport_implementations = [
739
'bzrlib.tests.test_transport_implementations']
741
TestCase.BZRPATH = osutils.pathjoin(
742
osutils.realpath(osutils.dirname(bzrlib.__path__[0])), 'bzr')
743
print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
744
print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
348
746
suite = TestSuite()
349
suite.addTest(TestLoader().loadTestsFromNames(testmod_names))
747
# python2.4's TestLoader.loadTestsFromNames gives very poor
748
# errors if it fails to load a named module - no indication of what's
749
# actually wrong, just "no such module". We should probably override that
750
# class, but for the moment just load them ourselves. (mbp 20051202)
751
loader = TestLoader()
752
from bzrlib.transport import TransportTestProviderAdapter
753
adapter = TransportTestProviderAdapter()
754
for mod_name in test_transport_implementations:
755
mod = _load_module_by_name(mod_name)
756
for test in iter_suite_tests(loader.loadTestsFromModule(mod)):
757
suite.addTests(adapter.adapt(test))
758
for mod_name in testmod_names:
759
mod = _load_module_by_name(mod_name)
760
suite.addTest(loader.loadTestsFromModule(mod))
761
for package in packages_to_test():
762
suite.addTest(package.test_suite())
350
763
for m in MODULES_TO_TEST:
351
suite.addTest(TestLoader().loadTestsFromModule(m))
764
suite.addTest(loader.loadTestsFromModule(m))
352
765
for m in (MODULES_TO_DOCTEST):
353
766
suite.addTest(DocTestSuite(m))
354
for p in bzrlib.plugin.all_plugins:
355
if hasattr(p, 'test_suite'):
356
suite.addTest(p.test_suite())
767
for name, plugin in bzrlib.plugin.all_plugins().items():
768
if hasattr(plugin, 'test_suite'):
769
suite.addTest(plugin.test_suite())
773
def _load_module_by_name(mod_name):
774
parts = mod_name.split('.')
775
module = __import__(mod_name)
777
# for historical reasons python returns the top-level module even though
778
# it loads the submodule; we need to walk down to get the one we want.
780
module = getattr(module, parts.pop(0))