~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-22 18:24:25 UTC
  • mfrom: (1803 +trunk)
  • mto: (1793.3.6 bundle-fixes)
  • mto: This revision was merged to the branch mainline in revision 1806.
  • Revision ID: john@arbash-meinel.com-20060622182425-6f45cb7acd587216
[merge] bzr.dev 1804 and fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
import codecs
30
30
from cStringIO import StringIO
31
31
import difflib
 
32
import doctest
32
33
import errno
33
34
import logging
34
35
import os
69
70
from bzrlib.transport.local import LocalRelpathServer
70
71
from bzrlib.transport.readonly import ReadonlyServer
71
72
from bzrlib.trace import mutter
72
 
from bzrlib.tests.TestUtil import TestLoader, TestSuite
 
73
from bzrlib.tests import TestUtil
 
74
from bzrlib.tests.TestUtil import (
 
75
                          TestSuite,
 
76
                          TestLoader,
 
77
                          )
73
78
from bzrlib.tests.treeshape import build_tree_contents
74
79
import bzrlib.urlutils as urlutils
75
80
from bzrlib.workingtree import WorkingTree, WorkingTreeFormat2
334
339
                # If LANG=C we probably have created some bogus paths
335
340
                # which rmtree(unicode) will fail to delete
336
341
                # so make sure we are using rmtree(str) to delete everything
337
 
                osutils.rmtree(test_root.encode(
338
 
                    sys.getfilesystemencoding()))
 
342
                # except on win32, where rmtree(str) will fail
 
343
                # since it doesn't have the property of byte-stream paths
 
344
                # (they are either ascii or mbcs)
 
345
                if sys.platform == 'win32':
 
346
                    # make sure we are using the unicode win32 api
 
347
                    test_root = unicode(test_root)
 
348
                else:
 
349
                    test_root = test_root.encode(
 
350
                        sys.getfilesystemencoding())
 
351
                osutils.rmtree(test_root)
339
352
        else:
340
353
            if self.pb is not None:
341
354
                self.pb.note("Failed tests working directories are in '%s'\n",
676
689
        self.log('run bzr: %r', argv)
677
690
        # FIXME: don't call into logging here
678
691
        handler = logging.StreamHandler(stderr)
679
 
        handler.setFormatter(bzrlib.trace.QuietFormatter())
680
692
        handler.setLevel(logging.INFO)
681
693
        logger = logging.getLogger('')
682
694
        logger.addHandler(handler)
1129
1141
 
1130
1142
 
1131
1143
def filter_suite_by_re(suite, pattern):
1132
 
    result = TestSuite()
 
1144
    result = TestUtil.TestSuite()
1133
1145
    filter_re = re.compile(pattern)
1134
1146
    for test in iter_suite_tests(suite):
1135
1147
        if filter_re.search(test.id()):
1190
1202
    This function can be replaced if you need to change the default test
1191
1203
    suite on a global basis, but it is not encouraged.
1192
1204
    """
1193
 
    from doctest import DocTestSuite
1194
 
 
1195
 
    global MODULES_TO_DOCTEST
1196
 
 
1197
 
    testmod_names = [ \
 
1205
    testmod_names = [
1198
1206
                   'bzrlib.tests.test_ancestry',
1199
1207
                   'bzrlib.tests.test_api',
1200
1208
                   'bzrlib.tests.test_bad_files',
1274
1282
        'bzrlib.tests.test_transport_implementations',
1275
1283
        'bzrlib.tests.test_read_bundle',
1276
1284
        ]
1277
 
 
1278
 
    suite = TestSuite()
 
1285
    suite = TestUtil.TestSuite()
1279
1286
    loader = TestUtil.TestLoader()
1280
1287
    from bzrlib.transport import TransportTestProviderAdapter
1281
1288
    adapter = TransportTestProviderAdapter()
1285
1292
        suite.addTest(package.test_suite())
1286
1293
    for m in MODULES_TO_TEST:
1287
1294
        suite.addTest(loader.loadTestsFromModule(m))
1288
 
    for m in (MODULES_TO_DOCTEST):
1289
 
        suite.addTest(DocTestSuite(m))
 
1295
    for m in MODULES_TO_DOCTEST:
 
1296
        suite.addTest(doctest.DocTestSuite(m))
1290
1297
    for name, plugin in bzrlib.plugin.all_plugins().items():
1291
1298
        if getattr(plugin, 'test_suite', None) is not None:
1292
1299
            suite.addTest(plugin.test_suite())