174
195
self._overall_start_time = time.time()
175
196
self._strict = strict
178
# nb: called stopTestRun in the version of this that Python merged
179
# upstream, according to lifeless 20090803
198
def stopTestRun(self):
201
stopTime = time.time()
202
timeTaken = stopTime - self.startTime
204
self.stream.writeln(self.separator2)
205
self.stream.writeln("%s %d test%s in %.3fs" % (actionTaken,
206
run, run != 1 and "s" or "", timeTaken))
207
self.stream.writeln()
208
if not self.wasSuccessful():
209
self.stream.write("FAILED (")
210
failed, errored = map(len, (self.failures, self.errors))
212
self.stream.write("failures=%d" % failed)
214
if failed: self.stream.write(", ")
215
self.stream.write("errors=%d" % errored)
216
if self.known_failure_count:
217
if failed or errored: self.stream.write(", ")
218
self.stream.write("known_failure_count=%d" %
219
self.known_failure_count)
220
self.stream.writeln(")")
222
if self.known_failure_count:
223
self.stream.writeln("OK (known_failures=%d)" %
224
self.known_failure_count)
226
self.stream.writeln("OK")
227
if self.skip_count > 0:
228
skipped = self.skip_count
229
self.stream.writeln('%d test%s skipped' %
230
(skipped, skipped != 1 and "s" or ""))
232
for feature, count in sorted(self.unsupported.items()):
233
self.stream.writeln("Missing feature '%s' skipped %d tests." %
181
236
ok = self.wasStrictlySuccessful()
183
238
ok = self.wasSuccessful()
185
self.stream.write('tests passed\n')
187
self.stream.write('tests failed\n')
188
239
if TestCase._first_thread_leaker_id:
189
240
self.stream.write(
190
241
'%s is leaking threads among %d leaking tests.\n' % (
191
242
TestCase._first_thread_leaker_id,
192
243
TestCase._leaking_threads_tests))
194
def _extractBenchmarkTime(self, testCase):
244
# We don't report the main thread as an active one.
246
'%d non-main threads were left active in the end.\n'
247
% (TestCase._active_threads - 1))
249
def getDescription(self, test):
252
def _extractBenchmarkTime(self, testCase, details=None):
195
253
"""Add a benchmark time for the current test case."""
254
if details and 'benchtime' in details:
255
return float(''.join(details['benchtime'].iter_bytes()))
196
256
return getattr(testCase, "_benchtime", None)
198
258
def _elapsedTestTimeString(self):
571
597
bench_history=None,
599
result_decorators=None,
601
"""Create a TextTestRunner.
603
:param result_decorators: An optional list of decorators to apply
604
to the result object being used by the runner. Decorators are
605
applied left to right - the first element in the list is the
608
# stream may know claim to know to write unicode strings, but in older
609
# pythons this goes sufficiently wrong that it is a bad idea. (
610
# specifically a built in file with encoding 'UTF-8' will still try
611
# to encode using ascii.
612
new_encoding = osutils.get_terminal_encoding()
613
codec = codecs.lookup(new_encoding)
614
if type(codec) is tuple:
618
encode = codec.encode
619
stream = osutils.UnicodeOrBytesToBytesWriter(encode, stream)
620
stream.encoding = new_encoding
575
621
self.stream = unittest._WritelnDecorator(stream)
576
622
self.descriptions = descriptions
577
623
self.verbosity = verbosity
578
624
self._bench_history = bench_history
579
self.list_only = list_only
580
625
self._strict = strict
626
self._result_decorators = result_decorators or []
582
628
def run(self, test):
583
629
"Run the given test case or test suite."
584
startTime = time.time()
585
630
if self.verbosity == 1:
586
631
result_class = TextTestResult
587
632
elif self.verbosity >= 2:
588
633
result_class = VerboseTestResult
589
result = result_class(self.stream,
634
original_result = result_class(self.stream,
590
635
self.descriptions,
592
637
bench_history=self._bench_history,
593
638
strict=self._strict,
595
result.stop_early = self.stop_on_failure
596
result.report_starting()
598
if self.verbosity >= 2:
599
self.stream.writeln("Listing tests only ...\n")
601
for t in iter_suite_tests(test):
602
self.stream.writeln("%s" % (t.id()))
611
if isinstance(test, testtools.ConcurrentTestSuite):
612
# We need to catch bzr specific behaviors
613
test.run(BZRTransformingResult(result))
616
run = result.testsRun
618
stopTime = time.time()
619
timeTaken = stopTime - startTime
621
self.stream.writeln(result.separator2)
622
self.stream.writeln("%s %d test%s in %.3fs" % (actionTaken,
623
run, run != 1 and "s" or "", timeTaken))
624
self.stream.writeln()
625
if not result.wasSuccessful():
626
self.stream.write("FAILED (")
627
failed, errored = map(len, (result.failures, result.errors))
629
self.stream.write("failures=%d" % failed)
631
if failed: self.stream.write(", ")
632
self.stream.write("errors=%d" % errored)
633
if result.known_failure_count:
634
if failed or errored: self.stream.write(", ")
635
self.stream.write("known_failure_count=%d" %
636
result.known_failure_count)
637
self.stream.writeln(")")
639
if result.known_failure_count:
640
self.stream.writeln("OK (known_failures=%d)" %
641
result.known_failure_count)
643
self.stream.writeln("OK")
644
if result.skip_count > 0:
645
skipped = result.skip_count
646
self.stream.writeln('%d test%s skipped' %
647
(skipped, skipped != 1 and "s" or ""))
648
if result.unsupported:
649
for feature, count in sorted(result.unsupported.items()):
650
self.stream.writeln("Missing feature '%s' skipped %d tests." %
640
# Signal to result objects that look at stop early policy to stop,
641
original_result.stop_early = self.stop_on_failure
642
result = original_result
643
for decorator in self._result_decorators:
644
result = decorator(result)
645
result.stop_early = self.stop_on_failure
646
result.startTestRun()
651
# higher level code uses our extended protocol to determine
652
# what exit code to give.
653
return original_result
656
656
def iter_suite_tests(suite):
917
940
def _lock_broken(self, result):
918
941
self._lock_actions.append(('broken', result))
943
def permit_dir(self, name):
944
"""Permit a directory to be used by this test. See permit_url."""
945
name_transport = _mod_transport.get_transport(name)
946
self.permit_url(name)
947
self.permit_url(name_transport.base)
949
def permit_url(self, url):
950
"""Declare that url is an ok url to use in this test.
952
Do this for memory transports, temporary test directory etc.
954
Do not do this for the current working directory, /tmp, or any other
955
preexisting non isolated url.
957
if not url.endswith('/'):
959
self._bzr_selftest_roots.append(url)
961
def permit_source_tree_branch_repo(self):
962
"""Permit the source tree bzr is running from to be opened.
964
Some code such as bzrlib.version attempts to read from the bzr branch
965
that bzr is executing from (if any). This method permits that directory
966
to be used in the test suite.
968
path = self.get_source_path()
969
self.record_directory_isolation()
972
workingtree.WorkingTree.open(path)
973
except (errors.NotBranchError, errors.NoWorkingTree):
976
self.enable_directory_isolation()
978
def _preopen_isolate_transport(self, transport):
979
"""Check that all transport openings are done in the test work area."""
980
while isinstance(transport, pathfilter.PathFilteringTransport):
981
# Unwrap pathfiltered transports
982
transport = transport.server.backing_transport.clone(
983
transport._filter('.'))
985
# ReadonlySmartTCPServer_for_testing decorates the backing transport
986
# urls it is given by prepending readonly+. This is appropriate as the
987
# client shouldn't know that the server is readonly (or not readonly).
988
# We could register all servers twice, with readonly+ prepending, but
989
# that makes for a long list; this is about the same but easier to
991
if url.startswith('readonly+'):
992
url = url[len('readonly+'):]
993
self._preopen_isolate_url(url)
995
def _preopen_isolate_url(self, url):
996
if not self._directory_isolation:
998
if self._directory_isolation == 'record':
999
self._bzr_selftest_roots.append(url)
1001
# This prevents all transports, including e.g. sftp ones backed on disk
1002
# from working unless they are explicitly granted permission. We then
1003
# depend on the code that sets up test transports to check that they are
1004
# appropriately isolated and enable their use by calling
1005
# self.permit_transport()
1006
if not osutils.is_inside_any(self._bzr_selftest_roots, url):
1007
raise errors.BzrError("Attempt to escape test isolation: %r %r"
1008
% (url, self._bzr_selftest_roots))
1010
def record_directory_isolation(self):
1011
"""Gather accessed directories to permit later access.
1013
This is used for tests that access the branch bzr is running from.
1015
self._directory_isolation = "record"
1017
def start_server(self, transport_server, backing_server=None):
1018
"""Start transport_server for this test.
1020
This starts the server, registers a cleanup for it and permits the
1021
server's urls to be used.
1023
if backing_server is None:
1024
transport_server.start_server()
1026
transport_server.start_server(backing_server)
1027
self.addCleanup(transport_server.stop_server)
1028
# Obtain a real transport because if the server supplies a password, it
1029
# will be hidden from the base on the client side.
1030
t = _mod_transport.get_transport(transport_server.get_url())
1031
# Some transport servers effectively chroot the backing transport;
1032
# others like SFTPServer don't - users of the transport can walk up the
1033
# transport to read the entire backing transport. This wouldn't matter
1034
# except that the workdir tests are given - and that they expect the
1035
# server's url to point at - is one directory under the safety net. So
1036
# Branch operations into the transport will attempt to walk up one
1037
# directory. Chrooting all servers would avoid this but also mean that
1038
# we wouldn't be testing directly against non-root urls. Alternatively
1039
# getting the test framework to start the server with a backing server
1040
# at the actual safety net directory would work too, but this then
1041
# means that the self.get_url/self.get_transport methods would need
1042
# to transform all their results. On balance its cleaner to handle it
1043
# here, and permit a higher url when we have one of these transports.
1044
if t.base.endswith('/work/'):
1045
# we have safety net/test root/work
1046
t = t.clone('../..')
1047
elif isinstance(transport_server,
1048
test_server.SmartTCPServer_for_testing):
1049
# The smart server adds a path similar to work, which is traversed
1050
# up from by the client. But the server is chrooted - the actual
1051
# backing transport is not escaped from, and VFS requests to the
1052
# root will error (because they try to escape the chroot).
1054
while t2.base != t.base:
1057
self.permit_url(t.base)
1059
def _track_transports(self):
1060
"""Install checks for transport usage."""
1061
# TestCase has no safe place it can write to.
1062
self._bzr_selftest_roots = []
1063
# Currently the easiest way to be sure that nothing is going on is to
1064
# hook into bzr dir opening. This leaves a small window of error for
1065
# transport tests, but they are well known, and we can improve on this
1067
bzrdir.BzrDir.hooks.install_named_hook("pre_open",
1068
self._preopen_isolate_transport, "Check bzr directories are safe.")
920
1070
def _ndiff_strings(self, a, b):
921
1071
"""Return ndiff between two strings containing lines.
1397
1585
def _do_skip(self, result, reason):
1398
1586
addSkip = getattr(result, 'addSkip', None)
1399
1587
if not callable(addSkip):
1400
result.addError(self, sys.exc_info())
1588
result.addSuccess(result)
1402
1590
addSkip(self, reason)
1404
def run(self, result=None):
1405
if result is None: result = self.defaultTestResult()
1406
for feature in getattr(self, '_test_needs_features', []):
1407
if not feature.available():
1408
result.startTest(self)
1409
if getattr(result, 'addNotSupported', None):
1410
result.addNotSupported(self, feature)
1412
result.addSuccess(self)
1413
result.stopTest(self)
1417
result.startTest(self)
1418
absent_attr = object()
1420
method_name = getattr(self, '_testMethodName', absent_attr)
1421
if method_name is absent_attr:
1423
method_name = getattr(self, '_TestCase__testMethodName')
1424
testMethod = getattr(self, method_name)
1428
if not self._bzr_test_setUp_run:
1430
"test setUp did not invoke "
1431
"bzrlib.tests.TestCase's setUp")
1432
except KeyboardInterrupt:
1435
except TestSkipped, e:
1436
self._do_skip(result, e.args[0])
1440
result.addError(self, sys.exc_info())
1448
except self.failureException:
1449
result.addFailure(self, sys.exc_info())
1450
except TestSkipped, e:
1452
reason = "No reason given."
1455
self._do_skip(result, reason)
1456
except KeyboardInterrupt:
1460
result.addError(self, sys.exc_info())
1464
if not self._bzr_test_tearDown_run:
1466
"test tearDown did not invoke "
1467
"bzrlib.tests.TestCase's tearDown")
1468
except KeyboardInterrupt:
1472
result.addError(self, sys.exc_info())
1475
if ok: result.addSuccess(self)
1477
result.stopTest(self)
1479
except TestNotApplicable:
1480
# Not moved from the result [yet].
1483
except KeyboardInterrupt:
1488
for attr_name in self.attrs_to_keep:
1489
if attr_name in self.__dict__:
1490
saved_attrs[attr_name] = self.__dict__[attr_name]
1491
self.__dict__ = saved_attrs
1495
self._log_contents = ''
1496
self._bzr_test_tearDown_run = True
1497
unittest.TestCase.tearDown(self)
1593
def _do_known_failure(self, result, e):
1594
err = sys.exc_info()
1595
addExpectedFailure = getattr(result, 'addExpectedFailure', None)
1596
if addExpectedFailure is not None:
1597
addExpectedFailure(self, err)
1599
result.addSuccess(self)
1602
def _do_not_applicable(self, result, e):
1604
reason = 'No reason given'
1607
addNotApplicable = getattr(result, 'addNotApplicable', None)
1608
if addNotApplicable is not None:
1609
result.addNotApplicable(self, reason)
1611
self._do_skip(result, reason)
1614
def _do_unsupported_or_skip(self, result, e):
1616
addNotSupported = getattr(result, 'addNotSupported', None)
1617
if addNotSupported is not None:
1618
result.addNotSupported(self, reason)
1620
self._do_skip(result, reason)
1499
1622
def time(self, callable, *args, **kwargs):
1500
1623
"""Run callable and accrue the time it takes to the benchmark time.
3137
3354
def addSuccess(self, test):
3138
3355
self.result.addSuccess(test)
3140
def _error_looks_like(self, prefix, err):
3141
"""Deserialize exception and returns the stringify value."""
3145
if isinstance(exc, subunit.RemoteException):
3146
# stringify the exception gives access to the remote traceback
3147
# We search the last line for 'prefix'
3148
lines = str(exc).split('\n')
3149
while lines and not lines[-1]:
3152
if lines[-1].startswith(prefix):
3153
value = lines[-1][len(prefix):]
3357
def addError(self, test, err):
3358
self.result.addError(test, err)
3360
def addFailure(self, test, err):
3361
self.result.addFailure(test, err)
3362
ForwardingResult = testtools.ExtendedToOriginalDecorator
3365
class ProfileResult(ForwardingResult):
3366
"""Generate profiling data for all activity between start and success.
3368
The profile data is appended to the test's _benchcalls attribute and can
3369
be accessed by the forwarded-to TestResult.
3371
While it might be cleaner do accumulate this in stopTest, addSuccess is
3372
where our existing output support for lsprof is, and this class aims to
3373
fit in with that: while it could be moved it's not necessary to accomplish
3374
test profiling, nor would it be dramatically cleaner.
3377
def startTest(self, test):
3378
self.profiler = bzrlib.lsprof.BzrProfiler()
3379
# Prevent deadlocks in tests that use lsprof: those tests will
3381
bzrlib.lsprof.BzrProfiler.profiler_block = 0
3382
self.profiler.start()
3383
ForwardingResult.startTest(self, test)
3385
def addSuccess(self, test):
3386
stats = self.profiler.stop()
3388
calls = test._benchcalls
3389
except AttributeError:
3390
test._benchcalls = []
3391
calls = test._benchcalls
3392
calls.append(((test.id(), "", ""), stats))
3393
ForwardingResult.addSuccess(self, test)
3395
def stopTest(self, test):
3396
ForwardingResult.stopTest(self, test)
3397
self.profiler = None
3157
3400
# Controlled by "bzr selftest -E=..." option
3401
# Currently supported:
3402
# -Eallow_debug Will no longer clear debug.debug_flags() so it
3403
# preserves any flags supplied at the command line.
3404
# -Edisable_lock_checks Turns errors in mismatched locks into simple prints
3405
# rather than failing tests. And no longer raise
3406
# LockContention when fctnl locks are not being used
3407
# with proper exclusion rules.
3158
3408
selftest_debug_flags = set()
3372
3637
test_prefix_alias_registry.register('bp', 'bzrlib.plugins')
3640
def _test_suite_testmod_names():
3641
"""Return the standard list of test module names to test."""
3644
'bzrlib.tests.blackbox',
3645
'bzrlib.tests.commands',
3646
'bzrlib.tests.per_branch',
3647
'bzrlib.tests.per_bzrdir',
3648
'bzrlib.tests.per_bzrdir_colo',
3649
'bzrlib.tests.per_foreign_vcs',
3650
'bzrlib.tests.per_interrepository',
3651
'bzrlib.tests.per_intertree',
3652
'bzrlib.tests.per_inventory',
3653
'bzrlib.tests.per_interbranch',
3654
'bzrlib.tests.per_lock',
3655
'bzrlib.tests.per_merger',
3656
'bzrlib.tests.per_transport',
3657
'bzrlib.tests.per_tree',
3658
'bzrlib.tests.per_pack_repository',
3659
'bzrlib.tests.per_repository',
3660
'bzrlib.tests.per_repository_chk',
3661
'bzrlib.tests.per_repository_reference',
3662
'bzrlib.tests.per_uifactory',
3663
'bzrlib.tests.per_versionedfile',
3664
'bzrlib.tests.per_workingtree',
3665
'bzrlib.tests.test__annotator',
3666
'bzrlib.tests.test__bencode',
3667
'bzrlib.tests.test__chk_map',
3668
'bzrlib.tests.test__dirstate_helpers',
3669
'bzrlib.tests.test__groupcompress',
3670
'bzrlib.tests.test__known_graph',
3671
'bzrlib.tests.test__rio',
3672
'bzrlib.tests.test__simple_set',
3673
'bzrlib.tests.test__static_tuple',
3674
'bzrlib.tests.test__walkdirs_win32',
3675
'bzrlib.tests.test_ancestry',
3676
'bzrlib.tests.test_annotate',
3677
'bzrlib.tests.test_api',
3678
'bzrlib.tests.test_atomicfile',
3679
'bzrlib.tests.test_bad_files',
3680
'bzrlib.tests.test_bisect_multi',
3681
'bzrlib.tests.test_branch',
3682
'bzrlib.tests.test_branchbuilder',
3683
'bzrlib.tests.test_btree_index',
3684
'bzrlib.tests.test_bugtracker',
3685
'bzrlib.tests.test_bundle',
3686
'bzrlib.tests.test_bzrdir',
3687
'bzrlib.tests.test__chunks_to_lines',
3688
'bzrlib.tests.test_cache_utf8',
3689
'bzrlib.tests.test_chk_map',
3690
'bzrlib.tests.test_chk_serializer',
3691
'bzrlib.tests.test_chunk_writer',
3692
'bzrlib.tests.test_clean_tree',
3693
'bzrlib.tests.test_cleanup',
3694
'bzrlib.tests.test_cmdline',
3695
'bzrlib.tests.test_commands',
3696
'bzrlib.tests.test_commit',
3697
'bzrlib.tests.test_commit_merge',
3698
'bzrlib.tests.test_config',
3699
'bzrlib.tests.test_conflicts',
3700
'bzrlib.tests.test_counted_lock',
3701
'bzrlib.tests.test_crash',
3702
'bzrlib.tests.test_decorators',
3703
'bzrlib.tests.test_delta',
3704
'bzrlib.tests.test_debug',
3705
'bzrlib.tests.test_deprecated_graph',
3706
'bzrlib.tests.test_diff',
3707
'bzrlib.tests.test_directory_service',
3708
'bzrlib.tests.test_dirstate',
3709
'bzrlib.tests.test_email_message',
3710
'bzrlib.tests.test_eol_filters',
3711
'bzrlib.tests.test_errors',
3712
'bzrlib.tests.test_export',
3713
'bzrlib.tests.test_extract',
3714
'bzrlib.tests.test_fetch',
3715
'bzrlib.tests.test_fixtures',
3716
'bzrlib.tests.test_fifo_cache',
3717
'bzrlib.tests.test_filters',
3718
'bzrlib.tests.test_ftp_transport',
3719
'bzrlib.tests.test_foreign',
3720
'bzrlib.tests.test_generate_docs',
3721
'bzrlib.tests.test_generate_ids',
3722
'bzrlib.tests.test_globbing',
3723
'bzrlib.tests.test_gpg',
3724
'bzrlib.tests.test_graph',
3725
'bzrlib.tests.test_groupcompress',
3726
'bzrlib.tests.test_hashcache',
3727
'bzrlib.tests.test_help',
3728
'bzrlib.tests.test_hooks',
3729
'bzrlib.tests.test_http',
3730
'bzrlib.tests.test_http_response',
3731
'bzrlib.tests.test_https_ca_bundle',
3732
'bzrlib.tests.test_identitymap',
3733
'bzrlib.tests.test_ignores',
3734
'bzrlib.tests.test_index',
3735
'bzrlib.tests.test_import_tariff',
3736
'bzrlib.tests.test_info',
3737
'bzrlib.tests.test_inv',
3738
'bzrlib.tests.test_inventory_delta',
3739
'bzrlib.tests.test_knit',
3740
'bzrlib.tests.test_lazy_import',
3741
'bzrlib.tests.test_lazy_regex',
3742
'bzrlib.tests.test_library_state',
3743
'bzrlib.tests.test_lock',
3744
'bzrlib.tests.test_lockable_files',
3745
'bzrlib.tests.test_lockdir',
3746
'bzrlib.tests.test_log',
3747
'bzrlib.tests.test_lru_cache',
3748
'bzrlib.tests.test_lsprof',
3749
'bzrlib.tests.test_mail_client',
3750
'bzrlib.tests.test_matchers',
3751
'bzrlib.tests.test_memorytree',
3752
'bzrlib.tests.test_merge',
3753
'bzrlib.tests.test_merge3',
3754
'bzrlib.tests.test_merge_core',
3755
'bzrlib.tests.test_merge_directive',
3756
'bzrlib.tests.test_missing',
3757
'bzrlib.tests.test_msgeditor',
3758
'bzrlib.tests.test_multiparent',
3759
'bzrlib.tests.test_mutabletree',
3760
'bzrlib.tests.test_nonascii',
3761
'bzrlib.tests.test_options',
3762
'bzrlib.tests.test_osutils',
3763
'bzrlib.tests.test_osutils_encodings',
3764
'bzrlib.tests.test_pack',
3765
'bzrlib.tests.test_patch',
3766
'bzrlib.tests.test_patches',
3767
'bzrlib.tests.test_permissions',
3768
'bzrlib.tests.test_plugins',
3769
'bzrlib.tests.test_progress',
3770
'bzrlib.tests.test_read_bundle',
3771
'bzrlib.tests.test_reconcile',
3772
'bzrlib.tests.test_reconfigure',
3773
'bzrlib.tests.test_registry',
3774
'bzrlib.tests.test_remote',
3775
'bzrlib.tests.test_rename_map',
3776
'bzrlib.tests.test_repository',
3777
'bzrlib.tests.test_revert',
3778
'bzrlib.tests.test_revision',
3779
'bzrlib.tests.test_revisionspec',
3780
'bzrlib.tests.test_revisiontree',
3781
'bzrlib.tests.test_rio',
3782
'bzrlib.tests.test_rules',
3783
'bzrlib.tests.test_sampler',
3784
'bzrlib.tests.test_script',
3785
'bzrlib.tests.test_selftest',
3786
'bzrlib.tests.test_serializer',
3787
'bzrlib.tests.test_setup',
3788
'bzrlib.tests.test_sftp_transport',
3789
'bzrlib.tests.test_shelf',
3790
'bzrlib.tests.test_shelf_ui',
3791
'bzrlib.tests.test_smart',
3792
'bzrlib.tests.test_smart_add',
3793
'bzrlib.tests.test_smart_request',
3794
'bzrlib.tests.test_smart_transport',
3795
'bzrlib.tests.test_smtp_connection',
3796
'bzrlib.tests.test_source',
3797
'bzrlib.tests.test_ssh_transport',
3798
'bzrlib.tests.test_status',
3799
'bzrlib.tests.test_store',
3800
'bzrlib.tests.test_strace',
3801
'bzrlib.tests.test_subsume',
3802
'bzrlib.tests.test_switch',
3803
'bzrlib.tests.test_symbol_versioning',
3804
'bzrlib.tests.test_tag',
3805
'bzrlib.tests.test_testament',
3806
'bzrlib.tests.test_textfile',
3807
'bzrlib.tests.test_textmerge',
3808
'bzrlib.tests.test_timestamp',
3809
'bzrlib.tests.test_trace',
3810
'bzrlib.tests.test_transactions',
3811
'bzrlib.tests.test_transform',
3812
'bzrlib.tests.test_transport',
3813
'bzrlib.tests.test_transport_log',
3814
'bzrlib.tests.test_tree',
3815
'bzrlib.tests.test_treebuilder',
3816
'bzrlib.tests.test_treeshape',
3817
'bzrlib.tests.test_tsort',
3818
'bzrlib.tests.test_tuned_gzip',
3819
'bzrlib.tests.test_ui',
3820
'bzrlib.tests.test_uncommit',
3821
'bzrlib.tests.test_upgrade',
3822
'bzrlib.tests.test_upgrade_stacked',
3823
'bzrlib.tests.test_urlutils',
3824
'bzrlib.tests.test_version',
3825
'bzrlib.tests.test_version_info',
3826
'bzrlib.tests.test_weave',
3827
'bzrlib.tests.test_whitebox',
3828
'bzrlib.tests.test_win32utils',
3829
'bzrlib.tests.test_workingtree',
3830
'bzrlib.tests.test_workingtree_4',
3831
'bzrlib.tests.test_wsgi',
3832
'bzrlib.tests.test_xml',
3836
def _test_suite_modules_to_doctest():
3837
"""Return the list of modules to doctest."""
3839
# GZ 2009-03-31: No docstrings with -OO so there's nothing to doctest
3843
'bzrlib.branchbuilder',
3844
'bzrlib.decorators',
3847
'bzrlib.iterablefile',
3851
'bzrlib.symbol_versioning',
3853
'bzrlib.tests.fixtures',
3855
'bzrlib.version_info_formats.format_custom',
3375
3859
def test_suite(keep_only=None, starting_with=None):
3376
3860
"""Build and return TestSuite for the whole of bzrlib.
3383
3867
This function can be replaced if you need to change the default test
3384
3868
suite on a global basis, but it is not encouraged.
3388
'bzrlib.tests.blackbox',
3389
'bzrlib.tests.commands',
3390
'bzrlib.tests.per_branch',
3391
'bzrlib.tests.per_bzrdir',
3392
'bzrlib.tests.per_interrepository',
3393
'bzrlib.tests.per_intertree',
3394
'bzrlib.tests.per_inventory',
3395
'bzrlib.tests.per_interbranch',
3396
'bzrlib.tests.per_lock',
3397
'bzrlib.tests.per_transport',
3398
'bzrlib.tests.per_tree',
3399
'bzrlib.tests.per_pack_repository',
3400
'bzrlib.tests.per_repository',
3401
'bzrlib.tests.per_repository_chk',
3402
'bzrlib.tests.per_repository_reference',
3403
'bzrlib.tests.per_workingtree',
3404
'bzrlib.tests.test__annotator',
3405
'bzrlib.tests.test__chk_map',
3406
'bzrlib.tests.test__dirstate_helpers',
3407
'bzrlib.tests.test__groupcompress',
3408
'bzrlib.tests.test__known_graph',
3409
'bzrlib.tests.test__rio',
3410
'bzrlib.tests.test__walkdirs_win32',
3411
'bzrlib.tests.test_ancestry',
3412
'bzrlib.tests.test_annotate',
3413
'bzrlib.tests.test_api',
3414
'bzrlib.tests.test_atomicfile',
3415
'bzrlib.tests.test_bad_files',
3416
'bzrlib.tests.test_bencode',
3417
'bzrlib.tests.test_bisect_multi',
3418
'bzrlib.tests.test_branch',
3419
'bzrlib.tests.test_branchbuilder',
3420
'bzrlib.tests.test_btree_index',
3421
'bzrlib.tests.test_bugtracker',
3422
'bzrlib.tests.test_bundle',
3423
'bzrlib.tests.test_bzrdir',
3424
'bzrlib.tests.test__chunks_to_lines',
3425
'bzrlib.tests.test_cache_utf8',
3426
'bzrlib.tests.test_chk_map',
3427
'bzrlib.tests.test_chk_serializer',
3428
'bzrlib.tests.test_chunk_writer',
3429
'bzrlib.tests.test_clean_tree',
3430
'bzrlib.tests.test_commands',
3431
'bzrlib.tests.test_commit',
3432
'bzrlib.tests.test_commit_merge',
3433
'bzrlib.tests.test_config',
3434
'bzrlib.tests.test_conflicts',
3435
'bzrlib.tests.test_counted_lock',
3436
'bzrlib.tests.test_decorators',
3437
'bzrlib.tests.test_delta',
3438
'bzrlib.tests.test_debug',
3439
'bzrlib.tests.test_deprecated_graph',
3440
'bzrlib.tests.test_diff',
3441
'bzrlib.tests.test_directory_service',
3442
'bzrlib.tests.test_dirstate',
3443
'bzrlib.tests.test_email_message',
3444
'bzrlib.tests.test_eol_filters',
3445
'bzrlib.tests.test_errors',
3446
'bzrlib.tests.test_export',
3447
'bzrlib.tests.test_extract',
3448
'bzrlib.tests.test_fetch',
3449
'bzrlib.tests.test_fifo_cache',
3450
'bzrlib.tests.test_filters',
3451
'bzrlib.tests.test_ftp_transport',
3452
'bzrlib.tests.test_foreign',
3453
'bzrlib.tests.test_generate_docs',
3454
'bzrlib.tests.test_generate_ids',
3455
'bzrlib.tests.test_globbing',
3456
'bzrlib.tests.test_gpg',
3457
'bzrlib.tests.test_graph',
3458
'bzrlib.tests.test_groupcompress',
3459
'bzrlib.tests.test_hashcache',
3460
'bzrlib.tests.test_help',
3461
'bzrlib.tests.test_hooks',
3462
'bzrlib.tests.test_http',
3463
'bzrlib.tests.test_http_response',
3464
'bzrlib.tests.test_https_ca_bundle',
3465
'bzrlib.tests.test_identitymap',
3466
'bzrlib.tests.test_ignores',
3467
'bzrlib.tests.test_index',
3468
'bzrlib.tests.test_info',
3469
'bzrlib.tests.test_inv',
3470
'bzrlib.tests.test_inventory_delta',
3471
'bzrlib.tests.test_knit',
3472
'bzrlib.tests.test_lazy_import',
3473
'bzrlib.tests.test_lazy_regex',
3474
'bzrlib.tests.test_lockable_files',
3475
'bzrlib.tests.test_lockdir',
3476
'bzrlib.tests.test_log',
3477
'bzrlib.tests.test_lru_cache',
3478
'bzrlib.tests.test_lsprof',
3479
'bzrlib.tests.test_mail_client',
3480
'bzrlib.tests.test_memorytree',
3481
'bzrlib.tests.test_merge',
3482
'bzrlib.tests.test_merge3',
3483
'bzrlib.tests.test_merge_core',
3484
'bzrlib.tests.test_merge_directive',
3485
'bzrlib.tests.test_missing',
3486
'bzrlib.tests.test_msgeditor',
3487
'bzrlib.tests.test_multiparent',
3488
'bzrlib.tests.test_mutabletree',
3489
'bzrlib.tests.test_nonascii',
3490
'bzrlib.tests.test_options',
3491
'bzrlib.tests.test_osutils',
3492
'bzrlib.tests.test_osutils_encodings',
3493
'bzrlib.tests.test_pack',
3494
'bzrlib.tests.test_patch',
3495
'bzrlib.tests.test_patches',
3496
'bzrlib.tests.test_permissions',
3497
'bzrlib.tests.test_plugins',
3498
'bzrlib.tests.test_progress',
3499
'bzrlib.tests.test_read_bundle',
3500
'bzrlib.tests.test_reconcile',
3501
'bzrlib.tests.test_reconfigure',
3502
'bzrlib.tests.test_registry',
3503
'bzrlib.tests.test_remote',
3504
'bzrlib.tests.test_rename_map',
3505
'bzrlib.tests.test_repository',
3506
'bzrlib.tests.test_revert',
3507
'bzrlib.tests.test_revision',
3508
'bzrlib.tests.test_revisionspec',
3509
'bzrlib.tests.test_revisiontree',
3510
'bzrlib.tests.test_rio',
3511
'bzrlib.tests.test_rules',
3512
'bzrlib.tests.test_sampler',
3513
'bzrlib.tests.test_selftest',
3514
'bzrlib.tests.test_serializer',
3515
'bzrlib.tests.test_setup',
3516
'bzrlib.tests.test_sftp_transport',
3517
'bzrlib.tests.test_shelf',
3518
'bzrlib.tests.test_shelf_ui',
3519
'bzrlib.tests.test_smart',
3520
'bzrlib.tests.test_smart_add',
3521
'bzrlib.tests.test_smart_request',
3522
'bzrlib.tests.test_smart_transport',
3523
'bzrlib.tests.test_smtp_connection',
3524
'bzrlib.tests.test_source',
3525
'bzrlib.tests.test_ssh_transport',
3526
'bzrlib.tests.test_status',
3527
'bzrlib.tests.test_store',
3528
'bzrlib.tests.test_strace',
3529
'bzrlib.tests.test_subsume',
3530
'bzrlib.tests.test_switch',
3531
'bzrlib.tests.test_symbol_versioning',
3532
'bzrlib.tests.test_tag',
3533
'bzrlib.tests.test_testament',
3534
'bzrlib.tests.test_textfile',
3535
'bzrlib.tests.test_textmerge',
3536
'bzrlib.tests.test_timestamp',
3537
'bzrlib.tests.test_trace',
3538
'bzrlib.tests.test_transactions',
3539
'bzrlib.tests.test_transform',
3540
'bzrlib.tests.test_transport',
3541
'bzrlib.tests.test_transport_log',
3542
'bzrlib.tests.test_tree',
3543
'bzrlib.tests.test_treebuilder',
3544
'bzrlib.tests.test_tsort',
3545
'bzrlib.tests.test_tuned_gzip',
3546
'bzrlib.tests.test_ui',
3547
'bzrlib.tests.test_uncommit',
3548
'bzrlib.tests.test_upgrade',
3549
'bzrlib.tests.test_upgrade_stacked',
3550
'bzrlib.tests.test_urlutils',
3551
'bzrlib.tests.test_version',
3552
'bzrlib.tests.test_version_info',
3553
'bzrlib.tests.test_versionedfile',
3554
'bzrlib.tests.test_weave',
3555
'bzrlib.tests.test_whitebox',
3556
'bzrlib.tests.test_win32utils',
3557
'bzrlib.tests.test_workingtree',
3558
'bzrlib.tests.test_workingtree_4',
3559
'bzrlib.tests.test_wsgi',
3560
'bzrlib.tests.test_xml',
3563
3871
loader = TestUtil.TestLoader()
3565
3873
if keep_only is not None:
3566
3874
id_filter = TestIdList(keep_only)
3567
3875
if starting_with:
3568
starting_with = [test_prefix_alias_registry.resolve_alias(start)
3569
for start in starting_with]
3570
3876
# We take precedence over keep_only because *at loading time* using
3571
3877
# both options means we will load less tests for the same final result.
3572
3878
def interesting_module(name):
3877
4209
UnicodeFilenameFeature = _UnicodeFilenameFeature()
4212
class _CompatabilityThunkFeature(Feature):
4213
"""This feature is just a thunk to another feature.
4215
It issues a deprecation warning if it is accessed, to let you know that you
4216
should really use a different feature.
4219
def __init__(self, dep_version, module, name,
4220
replacement_name, replacement_module=None):
4221
super(_CompatabilityThunkFeature, self).__init__()
4222
self._module = module
4223
if replacement_module is None:
4224
replacement_module = module
4225
self._replacement_module = replacement_module
4227
self._replacement_name = replacement_name
4228
self._dep_version = dep_version
4229
self._feature = None
4232
if self._feature is None:
4233
depr_msg = self._dep_version % ('%s.%s'
4234
% (self._module, self._name))
4235
use_msg = ' Use %s.%s instead.' % (self._replacement_module,
4236
self._replacement_name)
4237
symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning)
4238
# Import the new feature and use it as a replacement for the
4240
mod = __import__(self._replacement_module, {}, {},
4241
[self._replacement_name])
4242
self._feature = getattr(mod, self._replacement_name)
4246
return self._feature._probe()
4249
class ModuleAvailableFeature(Feature):
4250
"""This is a feature than describes a module we want to be available.
4252
Declare the name of the module in __init__(), and then after probing, the
4253
module will be available as 'self.module'.
4255
:ivar module: The module if it is available, else None.
4258
def __init__(self, module_name):
4259
super(ModuleAvailableFeature, self).__init__()
4260
self.module_name = module_name
4264
self._module = __import__(self.module_name, {}, {}, [''])
4271
if self.available(): # Make sure the probe has been done
4275
def feature_name(self):
4276
return self.module_name
4279
# This is kept here for compatibility, it is recommended to use
4280
# 'bzrlib.tests.feature.paramiko' instead
4281
ParamikoFeature = _CompatabilityThunkFeature(
4282
deprecated_in((2,1,0)),
4283
'bzrlib.tests.features', 'ParamikoFeature', 'paramiko')
3880
4286
def probe_unicode_in_user_encoding():
3881
4287
"""Try to encode several unicode strings to use in unicode-aware tests.
3882
4288
Return first successfull match.