~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-18 04:55:00 UTC
  • mfrom: (5784.2.1 754188-apport-test)
  • Revision ID: pqm@pqm.ubuntu.com-20110418045500-ce6lkgyiq7f47q43
(mbp) Rewrite test_report_bug_legacy away from using doctest (see bug
 764188) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
55
55
import testtools
56
56
# nb: check this before importing anything else from within it
57
57
_testtools_version = getattr(testtools, '__version__', ())
58
 
if _testtools_version < (0, 9, 2):
59
 
    raise ImportError("need at least testtools 0.9.2: %s is %r"
 
58
if _testtools_version < (0, 9, 5):
 
59
    raise ImportError("need at least testtools 0.9.5: %s is %r"
60
60
        % (testtools.__file__, _testtools_version))
61
61
from testtools import content
62
62
 
 
63
import bzrlib
63
64
from bzrlib import (
64
65
    branchbuilder,
65
66
    bzrdir,
66
67
    chk_map,
 
68
    commands as _mod_commands,
67
69
    config,
68
70
    debug,
69
71
    errors,
70
72
    hooks,
71
73
    lock as _mod_lock,
 
74
    lockdir,
72
75
    memorytree,
73
76
    osutils,
 
77
    plugin as _mod_plugin,
74
78
    pyutils,
75
79
    ui,
76
80
    urlutils,
77
81
    registry,
 
82
    symbol_versioning,
 
83
    trace,
78
84
    transport as _mod_transport,
79
85
    workingtree,
80
86
    )
81
 
import bzrlib.branch
82
 
import bzrlib.commands
83
 
import bzrlib.timestamp
84
 
import bzrlib.export
85
 
import bzrlib.inventory
86
 
import bzrlib.iterablefile
87
 
import bzrlib.lockdir
88
87
try:
89
88
    import bzrlib.lsprof
90
89
except ImportError:
91
90
    # lsprof not available
92
91
    pass
93
 
import bzrlib.merge3
94
 
import bzrlib.plugin
95
92
from bzrlib.smart import client, request
96
 
import bzrlib.store
97
 
from bzrlib import symbol_versioning
98
 
from bzrlib.symbol_versioning import (
99
 
    DEPRECATED_PARAMETER,
100
 
    deprecated_function,
101
 
    deprecated_in,
102
 
    deprecated_method,
103
 
    deprecated_passed,
104
 
    )
105
 
import bzrlib.trace
106
93
from bzrlib.transport import (
107
94
    memory,
108
95
    pathfilter,
109
96
    )
110
 
from bzrlib.trace import mutter, note
111
97
from bzrlib.tests import (
112
98
    test_server,
113
99
    TestUtil,
115
101
    )
116
102
from bzrlib.ui import NullProgressView
117
103
from bzrlib.ui.text import TextUIFactory
118
 
import bzrlib.version_info_formats.format_custom
119
104
 
120
105
# Mark this python module as being part of the implementation
121
106
# of unittest: this gives us better tracebacks where the last
138
123
TestSuite = TestUtil.TestSuite
139
124
TestLoader = TestUtil.TestLoader
140
125
 
 
126
# Tests should run in a clean and clearly defined environment. The goal is to
 
127
# keep them isolated from the running environment as mush as possible. The test
 
128
# framework ensures the variables defined below are set (or deleted if the
 
129
# value is None) before a test is run and reset to their original value after
 
130
# the test is run. Generally if some code depends on an environment variable,
 
131
# the tests should start without this variable in the environment. There are a
 
132
# few exceptions but you shouldn't violate this rule lightly.
 
133
isolated_environ = {
 
134
    'BZR_HOME': None,
 
135
    'HOME': None,
 
136
    # bzr now uses the Win32 API and doesn't rely on APPDATA, but the
 
137
    # tests do check our impls match APPDATA
 
138
    'BZR_EDITOR': None, # test_msgeditor manipulates this variable
 
139
    'VISUAL': None,
 
140
    'EDITOR': None,
 
141
    'BZR_EMAIL': None,
 
142
    'BZREMAIL': None, # may still be present in the environment
 
143
    'EMAIL': 'jrandom@example.com', # set EMAIL as bzr does not guess
 
144
    'BZR_PROGRESS_BAR': None,
 
145
    'BZR_LOG': None,
 
146
    'BZR_PLUGIN_PATH': None,
 
147
    'BZR_DISABLE_PLUGINS': None,
 
148
    'BZR_PLUGINS_AT': None,
 
149
    'BZR_CONCURRENCY': None,
 
150
    # Make sure that any text ui tests are consistent regardless of
 
151
    # the environment the test case is run in; you may want tests that
 
152
    # test other combinations.  'dumb' is a reasonable guess for tests
 
153
    # going to a pipe or a StringIO.
 
154
    'TERM': 'dumb',
 
155
    'LINES': '25',
 
156
    'COLUMNS': '80',
 
157
    'BZR_COLUMNS': '80',
 
158
    # Disable SSH Agent
 
159
    'SSH_AUTH_SOCK': None,
 
160
    # Proxies
 
161
    'http_proxy': None,
 
162
    'HTTP_PROXY': None,
 
163
    'https_proxy': None,
 
164
    'HTTPS_PROXY': None,
 
165
    'no_proxy': None,
 
166
    'NO_PROXY': None,
 
167
    'all_proxy': None,
 
168
    'ALL_PROXY': None,
 
169
    # Nobody cares about ftp_proxy, FTP_PROXY AFAIK. So far at
 
170
    # least. If you do (care), please update this comment
 
171
    # -- vila 20080401
 
172
    'ftp_proxy': None,
 
173
    'FTP_PROXY': None,
 
174
    'BZR_REMOTE_PATH': None,
 
175
    # Generally speaking, we don't want apport reporting on crashes in
 
176
    # the test envirnoment unless we're specifically testing apport,
 
177
    # so that it doesn't leak into the real system environment.  We
 
178
    # use an env var so it propagates to subprocesses.
 
179
    'APPORT_DISABLE': '1',
 
180
    }
 
181
 
 
182
 
 
183
def override_os_environ(test, env=None):
 
184
    """Modify os.environ keeping a copy.
 
185
    
 
186
    :param test: A test instance
 
187
 
 
188
    :param env: A dict containing variable definitions to be installed
 
189
    """
 
190
    if env is None:
 
191
        env = isolated_environ
 
192
    test._original_os_environ = dict([(var, value)
 
193
                                      for var, value in os.environ.iteritems()])
 
194
    for var, value in env.iteritems():
 
195
        osutils.set_or_unset_env(var, value)
 
196
        if var not in test._original_os_environ:
 
197
            # The var is new, add it with a value of None, so
 
198
            # restore_os_environ will delete it
 
199
            test._original_os_environ[var] = None
 
200
 
 
201
 
 
202
def restore_os_environ(test):
 
203
    """Restore os.environ to its original state.
 
204
 
 
205
    :param test: A test instance previously passed to override_os_environ.
 
206
    """
 
207
    for var, value in test._original_os_environ.iteritems():
 
208
        # Restore the original value (or delete it if the value has been set to
 
209
        # None in override_os_environ).
 
210
        osutils.set_or_unset_env(var, value)
 
211
 
 
212
 
141
213
class ExtendedTestResult(testtools.TextTestResult):
142
214
    """Accepts, reports and accumulates the results of running tests.
143
215
 
301
373
        addOnException = getattr(test, "addOnException", None)
302
374
        if addOnException is not None:
303
375
            addOnException(self._record_traceback_from_test)
304
 
        # Only check for thread leaks if the test case supports cleanups
305
 
        addCleanup = getattr(test, "addCleanup", None)
306
 
        if addCleanup is not None:
307
 
            addCleanup(self._check_leaked_threads, test)
 
376
        # Only check for thread leaks on bzrlib derived test cases
 
377
        if isinstance(test, TestCase):
 
378
            test.addCleanup(self._check_leaked_threads, test)
308
379
 
309
380
    def startTests(self):
310
381
        self.report_tests_starting()
651
722
            encode = codec[0]
652
723
        else:
653
724
            encode = codec.encode
654
 
        stream = osutils.UnicodeOrBytesToBytesWriter(encode, stream)
 
725
        # GZ 2010-09-08: Really we don't want to be writing arbitrary bytes,
 
726
        #                so should swap to the plain codecs.StreamWriter
 
727
        stream = osutils.UnicodeOrBytesToBytesWriter(encode, stream,
 
728
            "backslashreplace")
655
729
        stream.encoding = new_encoding
656
730
        self.stream = stream
657
731
        self.descriptions = descriptions
807
881
        return NullProgressView()
808
882
 
809
883
 
 
884
def isolated_doctest_setUp(test):
 
885
    override_os_environ(test)
 
886
 
 
887
 
 
888
def isolated_doctest_tearDown(test):
 
889
    restore_os_environ(test)
 
890
 
 
891
 
 
892
def IsolatedDocTestSuite(*args, **kwargs):
 
893
    """Overrides doctest.DocTestSuite to handle isolation.
 
894
 
 
895
    The method is really a factory and users are expected to use it as such.
 
896
    """
 
897
    
 
898
    kwargs['setUp'] = isolated_doctest_setUp
 
899
    kwargs['tearDown'] = isolated_doctest_tearDown
 
900
    return doctest.DocTestSuite(*args, **kwargs)
 
901
 
 
902
 
810
903
class TestCase(testtools.TestCase):
811
904
    """Base class for bzr unit tests.
812
905
 
861
954
        # between tests.  We should get rid of this altogether: bug 656694. --
862
955
        # mbp 20101008
863
956
        self.overrideAttr(bzrlib.trace, '_verbosity_level', 0)
 
957
        # Isolate config option expansion until its default value for bzrlib is
 
958
        # settled on or a the FIXME associated with _get_expand_default_value
 
959
        # is addressed -- vila 20110219
 
960
        self.overrideAttr(config, '_expand_default_value', None)
864
961
 
865
962
    def debug(self):
866
963
        # debug a frame up.
903
1000
        for key, (parent, name) in known_hooks.iter_parent_objects():
904
1001
            current_hooks = getattr(parent, name)
905
1002
            self._preserved_hooks[parent] = (name, current_hooks)
 
1003
        self._preserved_lazy_hooks = hooks._lazy_hooks
 
1004
        hooks._lazy_hooks = {}
906
1005
        self.addCleanup(self._restoreHooks)
907
1006
        for key, (parent, name) in known_hooks.iter_parent_objects():
908
1007
            factory = known_hooks.get(key)
1123
1222
        except UnicodeError, e:
1124
1223
            # If we can't compare without getting a UnicodeError, then
1125
1224
            # obviously they are different
1126
 
            mutter('UnicodeError: %s', e)
 
1225
            trace.mutter('UnicodeError: %s', e)
1127
1226
        if message:
1128
1227
            message += '\n'
1129
1228
        raise AssertionError("%snot equal:\na = %s\nb = %s\n"
1168
1267
                         'st_mtime did not match')
1169
1268
        self.assertEqual(expected.st_ctime, actual.st_ctime,
1170
1269
                         'st_ctime did not match')
1171
 
        if sys.platform != 'win32':
 
1270
        if sys.platform == 'win32':
1172
1271
            # On Win32 both 'dev' and 'ino' cannot be trusted. In python2.4 it
1173
1272
            # is 'dev' that varies, in python 2.5 (6?) it is st_ino that is
1174
 
            # odd. Regardless we shouldn't actually try to assert anything
1175
 
            # about their values
 
1273
            # odd. We just force it to always be 0 to avoid any problems.
 
1274
            self.assertEqual(0, expected.st_dev)
 
1275
            self.assertEqual(0, actual.st_dev)
 
1276
            self.assertEqual(0, expected.st_ino)
 
1277
            self.assertEqual(0, actual.st_ino)
 
1278
        else:
1176
1279
            self.assertEqual(expected.st_dev, actual.st_dev,
1177
1280
                             'st_dev did not match')
1178
1281
            self.assertEqual(expected.st_ino, actual.st_ino,
1189
1292
    def assertLogsError(self, exception_class, func, *args, **kwargs):
1190
1293
        """Assert that func(*args, **kwargs) quietly logs a specific exception.
1191
1294
        """
1192
 
        from bzrlib import trace
1193
1295
        captured = []
1194
1296
        orig_log_exception_quietly = trace.log_exception_quietly
1195
1297
        try:
1244
1346
        if haystack.find(needle) == -1:
1245
1347
            self.fail("string %r not found in '''%s'''" % (needle, haystack))
1246
1348
 
 
1349
    def assertNotContainsString(self, haystack, needle):
 
1350
        if haystack.find(needle) != -1:
 
1351
            self.fail("string %r found in '''%s'''" % (needle, haystack))
 
1352
 
1247
1353
    def assertSubset(self, sublist, superlist):
1248
1354
        """Assert that every entry in sublist is present in superlist."""
1249
1355
        missing = set(sublist) - set(superlist)
1338
1444
 
1339
1445
    def assertFileEqual(self, content, path):
1340
1446
        """Fail if path does not contain 'content'."""
1341
 
        self.failUnlessExists(path)
 
1447
        self.assertPathExists(path)
1342
1448
        f = file(path, 'rb')
1343
1449
        try:
1344
1450
            s = f.read()
1354
1460
        else:
1355
1461
            self.assertEqual(expected_docstring, obj.__doc__)
1356
1462
 
 
1463
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4)))
1357
1464
    def failUnlessExists(self, path):
 
1465
        return self.assertPathExists(path)
 
1466
 
 
1467
    def assertPathExists(self, path):
1358
1468
        """Fail unless path or paths, which may be abs or relative, exist."""
1359
1469
        if not isinstance(path, basestring):
1360
1470
            for p in path:
1361
 
                self.failUnlessExists(p)
 
1471
                self.assertPathExists(p)
1362
1472
        else:
1363
 
            self.failUnless(osutils.lexists(path),path+" does not exist")
 
1473
            self.assertTrue(osutils.lexists(path),
 
1474
                path + " does not exist")
1364
1475
 
 
1476
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4)))
1365
1477
    def failIfExists(self, path):
 
1478
        return self.assertPathDoesNotExist(path)
 
1479
 
 
1480
    def assertPathDoesNotExist(self, path):
1366
1481
        """Fail if path or paths, which may be abs or relative, exist."""
1367
1482
        if not isinstance(path, basestring):
1368
1483
            for p in path:
1369
 
                self.failIfExists(p)
 
1484
                self.assertPathDoesNotExist(p)
1370
1485
        else:
1371
 
            self.failIf(osutils.lexists(path),path+" exists")
 
1486
            self.assertFalse(osutils.lexists(path),
 
1487
                path + " exists")
1372
1488
 
1373
1489
    def _capture_deprecation_warnings(self, a_callable, *args, **kwargs):
1374
1490
        """A helper for callDeprecated and applyDeprecated.
1489
1605
        The file is removed as the test is torn down.
1490
1606
        """
1491
1607
        self._log_file = StringIO()
1492
 
        self._log_memento = bzrlib.trace.push_log_file(self._log_file)
 
1608
        self._log_memento = trace.push_log_file(self._log_file)
1493
1609
        self.addCleanup(self._finishLogFile)
1494
1610
 
1495
1611
    def _finishLogFile(self):
1497
1613
 
1498
1614
        Close the file and delete it, unless setKeepLogfile was called.
1499
1615
        """
1500
 
        if bzrlib.trace._trace_file:
 
1616
        if trace._trace_file:
1501
1617
            # flush the log file, to get all content
1502
 
            bzrlib.trace._trace_file.flush()
1503
 
        bzrlib.trace.pop_log_file(self._log_memento)
 
1618
            trace._trace_file.flush()
 
1619
        trace.pop_log_file(self._log_memento)
1504
1620
        # Cache the log result and delete the file on disk
1505
1621
        self._get_log(False)
1506
1622
 
1536
1652
            setattr(obj, attr_name, new)
1537
1653
        return value
1538
1654
 
 
1655
    def overrideEnv(self, name, new):
 
1656
        """Set an environment variable, and reset it after the test.
 
1657
 
 
1658
        :param name: The environment variable name.
 
1659
 
 
1660
        :param new: The value to set the variable to. If None, the 
 
1661
            variable is deleted from the environment.
 
1662
 
 
1663
        :returns: The actual variable value.
 
1664
        """
 
1665
        value = osutils.set_or_unset_env(name, new)
 
1666
        self.addCleanup(osutils.set_or_unset_env, name, value)
 
1667
        return value
 
1668
 
1539
1669
    def _cleanEnvironment(self):
1540
 
        new_env = {
1541
 
            'BZR_HOME': None, # Don't inherit BZR_HOME to all the tests.
1542
 
            'HOME': os.getcwd(),
1543
 
            # bzr now uses the Win32 API and doesn't rely on APPDATA, but the
1544
 
            # tests do check our impls match APPDATA
1545
 
            'BZR_EDITOR': None, # test_msgeditor manipulates this variable
1546
 
            'VISUAL': None,
1547
 
            'EDITOR': None,
1548
 
            'BZR_EMAIL': None,
1549
 
            'BZREMAIL': None, # may still be present in the environment
1550
 
            'EMAIL': 'jrandom@example.com', # set EMAIL as bzr does not guess
1551
 
            'BZR_PROGRESS_BAR': None,
1552
 
            'BZR_LOG': None,
1553
 
            'BZR_PLUGIN_PATH': None,
1554
 
            'BZR_DISABLE_PLUGINS': None,
1555
 
            'BZR_PLUGINS_AT': None,
1556
 
            'BZR_CONCURRENCY': None,
1557
 
            # Make sure that any text ui tests are consistent regardless of
1558
 
            # the environment the test case is run in; you may want tests that
1559
 
            # test other combinations.  'dumb' is a reasonable guess for tests
1560
 
            # going to a pipe or a StringIO.
1561
 
            'TERM': 'dumb',
1562
 
            'LINES': '25',
1563
 
            'COLUMNS': '80',
1564
 
            'BZR_COLUMNS': '80',
1565
 
            # SSH Agent
1566
 
            'SSH_AUTH_SOCK': None,
1567
 
            # Proxies
1568
 
            'http_proxy': None,
1569
 
            'HTTP_PROXY': None,
1570
 
            'https_proxy': None,
1571
 
            'HTTPS_PROXY': None,
1572
 
            'no_proxy': None,
1573
 
            'NO_PROXY': None,
1574
 
            'all_proxy': None,
1575
 
            'ALL_PROXY': None,
1576
 
            # Nobody cares about ftp_proxy, FTP_PROXY AFAIK. So far at
1577
 
            # least. If you do (care), please update this comment
1578
 
            # -- vila 20080401
1579
 
            'ftp_proxy': None,
1580
 
            'FTP_PROXY': None,
1581
 
            'BZR_REMOTE_PATH': None,
1582
 
            # Generally speaking, we don't want apport reporting on crashes in
1583
 
            # the test envirnoment unless we're specifically testing apport,
1584
 
            # so that it doesn't leak into the real system environment.  We
1585
 
            # use an env var so it propagates to subprocesses.
1586
 
            'APPORT_DISABLE': '1',
1587
 
        }
1588
 
        self._old_env = {}
1589
 
        self.addCleanup(self._restoreEnvironment)
1590
 
        for name, value in new_env.iteritems():
1591
 
            self._captureVar(name, value)
1592
 
 
1593
 
    def _captureVar(self, name, newvalue):
1594
 
        """Set an environment variable, and reset it when finished."""
1595
 
        self._old_env[name] = osutils.set_or_unset_env(name, newvalue)
1596
 
 
1597
 
    def _restoreEnvironment(self):
1598
 
        for name, value in self._old_env.iteritems():
1599
 
            osutils.set_or_unset_env(name, value)
 
1670
        for name, value in isolated_environ.iteritems():
 
1671
            self.overrideEnv(name, value)
1600
1672
 
1601
1673
    def _restoreHooks(self):
1602
1674
        for klass, (name, hooks) in self._preserved_hooks.items():
1603
1675
            setattr(klass, name, hooks)
 
1676
        hooks._lazy_hooks = self._preserved_lazy_hooks
1604
1677
 
1605
1678
    def knownFailure(self, reason):
1606
1679
        """This test has failed for some known reason."""
1696
1769
            self._benchtime += time.time() - start
1697
1770
 
1698
1771
    def log(self, *args):
1699
 
        mutter(*args)
 
1772
        trace.mutter(*args)
1700
1773
 
1701
1774
    def _get_log(self, keep_log_file=False):
1702
1775
        """Internal helper to get the log from bzrlib.trace for this test.
1787
1860
 
1788
1861
        try:
1789
1862
            try:
1790
 
                result = self.apply_redirected(ui.ui_factory.stdin,
 
1863
                result = self.apply_redirected(
 
1864
                    ui.ui_factory.stdin,
1791
1865
                    stdout, stderr,
1792
 
                    bzrlib.commands.run_bzr_catch_user_errors,
 
1866
                    _mod_commands.run_bzr_catch_user_errors,
1793
1867
                    args)
1794
1868
            except KeyboardInterrupt:
1795
1869
                # Reraise KeyboardInterrupt with contents of redirected stdout
2045
2119
        if retcode is not None and retcode != process.returncode:
2046
2120
            if process_args is None:
2047
2121
                process_args = "(unknown args)"
2048
 
            mutter('Output of bzr %s:\n%s', process_args, out)
2049
 
            mutter('Error for bzr %s:\n%s', process_args, err)
 
2122
            trace.mutter('Output of bzr %s:\n%s', process_args, out)
 
2123
            trace.mutter('Error for bzr %s:\n%s', process_args, err)
2050
2124
            self.fail('Command bzr %s failed with retcode %s != %s'
2051
2125
                      % (process_args, retcode, process.returncode))
2052
2126
        return [out, err]
2109
2183
 
2110
2184
        Tests that expect to provoke LockContention errors should call this.
2111
2185
        """
2112
 
        self.overrideAttr(bzrlib.lockdir, '_DEFAULT_TIMEOUT_SECONDS', 0)
 
2186
        self.overrideAttr(lockdir, '_DEFAULT_TIMEOUT_SECONDS', 0)
2113
2187
 
2114
2188
    def make_utf8_encoded_stringio(self, encoding_type=None):
2115
2189
        """Return a StringIOWrapper instance, that will encode Unicode
2439
2513
        test_home_dir = self.test_home_dir
2440
2514
        if isinstance(test_home_dir, unicode):
2441
2515
            test_home_dir = test_home_dir.encode(sys.getfilesystemencoding())
2442
 
        os.environ['HOME'] = test_home_dir
2443
 
        os.environ['BZR_HOME'] = test_home_dir
 
2516
        self.overrideEnv('HOME', test_home_dir)
 
2517
        self.overrideEnv('BZR_HOME', test_home_dir)
2444
2518
 
2445
2519
    def setUp(self):
2446
2520
        super(TestCaseWithMemoryTransport, self).setUp()
2451
2525
                self.addCleanup(t.disconnect)
2452
2526
            return t
2453
2527
 
2454
 
        orig_get_transport = self.overrideAttr(_mod_transport, '_get_transport',
 
2528
        orig_get_transport = self.overrideAttr(_mod_transport, 'get_transport',
2455
2529
                                               get_transport_with_cleanup)
2456
2530
        self._make_test_root()
2457
2531
        self.addCleanup(os.chdir, os.getcwdu())
3596
3670
                key, obj, help=help, info=info, override_existing=False)
3597
3671
        except KeyError:
3598
3672
            actual = self.get(key)
3599
 
            note('Test prefix alias %s is already used for %s, ignoring %s'
3600
 
                 % (key, actual, obj))
 
3673
            trace.note(
 
3674
                'Test prefix alias %s is already used for %s, ignoring %s'
 
3675
                % (key, actual, obj))
3601
3676
 
3602
3677
    def resolve_alias(self, id_start):
3603
3678
        """Replace the alias by the prefix in the given string.
3653
3728
        'bzrlib.tests.per_repository',
3654
3729
        'bzrlib.tests.per_repository_chk',
3655
3730
        'bzrlib.tests.per_repository_reference',
 
3731
        'bzrlib.tests.per_repository_vf',
3656
3732
        'bzrlib.tests.per_uifactory',
3657
3733
        'bzrlib.tests.per_versionedfile',
3658
3734
        'bzrlib.tests.per_workingtree',
3692
3768
        'bzrlib.tests.test_commit_merge',
3693
3769
        'bzrlib.tests.test_config',
3694
3770
        'bzrlib.tests.test_conflicts',
 
3771
        'bzrlib.tests.test_controldir',
3695
3772
        'bzrlib.tests.test_counted_lock',
3696
3773
        'bzrlib.tests.test_crash',
3697
3774
        'bzrlib.tests.test_decorators',
3748
3825
        'bzrlib.tests.test_merge3',
3749
3826
        'bzrlib.tests.test_merge_core',
3750
3827
        'bzrlib.tests.test_merge_directive',
 
3828
        'bzrlib.tests.test_mergetools',
3751
3829
        'bzrlib.tests.test_missing',
3752
3830
        'bzrlib.tests.test_msgeditor',
3753
3831
        'bzrlib.tests.test_multiparent',
3803
3881
        'bzrlib.tests.test_testament',
3804
3882
        'bzrlib.tests.test_textfile',
3805
3883
        'bzrlib.tests.test_textmerge',
 
3884
        'bzrlib.tests.test_cethread',
3806
3885
        'bzrlib.tests.test_timestamp',
3807
3886
        'bzrlib.tests.test_trace',
3808
3887
        'bzrlib.tests.test_transactions',
3841
3920
        'bzrlib',
3842
3921
        'bzrlib.branchbuilder',
3843
3922
        'bzrlib.decorators',
3844
 
        'bzrlib.export',
3845
3923
        'bzrlib.inventory',
3846
3924
        'bzrlib.iterablefile',
3847
3925
        'bzrlib.lockdir',
3911
3989
        try:
3912
3990
            # note that this really does mean "report only" -- doctest
3913
3991
            # still runs the rest of the examples
3914
 
            doc_suite = doctest.DocTestSuite(mod,
3915
 
                optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)
 
3992
            doc_suite = IsolatedDocTestSuite(
 
3993
                mod, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)
3916
3994
        except ValueError, e:
3917
3995
            print '**failed to get doctest for: %s\n%s' % (mod, e)
3918
3996
            raise
3921
3999
        suite.addTest(doc_suite)
3922
4000
 
3923
4001
    default_encoding = sys.getdefaultencoding()
3924
 
    for name, plugin in bzrlib.plugin.plugins().items():
 
4002
    for name, plugin in _mod_plugin.plugins().items():
3925
4003
        if not interesting_module(plugin.module.__name__):
3926
4004
            continue
3927
4005
        plugin_suite = plugin.test_suite()
3933
4011
        if plugin_suite is not None:
3934
4012
            suite.addTest(plugin_suite)
3935
4013
        if default_encoding != sys.getdefaultencoding():
3936
 
            bzrlib.trace.warning(
 
4014
            trace.warning(
3937
4015
                'Plugin "%s" tried to reset default encoding to: %s', name,
3938
4016
                sys.getdefaultencoding())
3939
4017
            reload(sys)
3954
4032
            # Some tests mentioned in the list are not in the test suite. The
3955
4033
            # list may be out of date, report to the tester.
3956
4034
            for id in not_found:
3957
 
                bzrlib.trace.warning('"%s" not found in the test suite', id)
 
4035
                trace.warning('"%s" not found in the test suite', id)
3958
4036
        for id in duplicates:
3959
 
            bzrlib.trace.warning('"%s" is used as an id by several tests', id)
 
4037
            trace.warning('"%s" is used as an id by several tests', id)
3960
4038
 
3961
4039
    return suite
3962
4040
 
4300
4378
        return self.module_name
4301
4379
 
4302
4380
 
4303
 
# This is kept here for compatibility, it is recommended to use
4304
 
# 'bzrlib.tests.feature.paramiko' instead
4305
 
ParamikoFeature = _CompatabilityThunkFeature(
4306
 
    deprecated_in((2,1,0)),
4307
 
    'bzrlib.tests.features', 'ParamikoFeature', 'paramiko')
4308
 
 
4309
 
 
4310
4381
def probe_unicode_in_user_encoding():
4311
4382
    """Try to encode several unicode strings to use in unicode-aware tests.
4312
4383
    Return first successfull match.
4499
4570
case_sensitive_filesystem_feature = _CaseSensitiveFilesystemFeature()
4500
4571
 
4501
4572
 
4502
 
# Kept for compatibility, use bzrlib.tests.features.subunit instead
4503
 
SubUnitFeature = _CompatabilityThunkFeature(
4504
 
    deprecated_in((2,1,0)),
4505
 
    'bzrlib.tests.features', 'SubUnitFeature', 'subunit')
4506
4573
# Only define SubUnitBzrRunner if subunit is available.
4507
4574
try:
4508
4575
    from subunit import TestProtocolClient