195
175
self._overall_start_time = time.time()
196
176
self._strict = strict
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." %
179
# nb: called stopTestRun in the version of this that Python merged
180
# upstream, according to lifeless 20090803
236
182
ok = self.wasStrictlySuccessful()
238
184
ok = self.wasSuccessful()
186
self.stream.write('tests passed\n')
188
self.stream.write('tests failed\n')
239
189
if TestCase._first_thread_leaker_id:
240
190
self.stream.write(
241
191
'%s is leaking threads among %d leaking tests.\n' % (
242
192
TestCase._first_thread_leaker_id,
243
193
TestCase._leaking_threads_tests))
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
def _extractBenchmarkTime(self, testCase):
253
196
"""Add a benchmark time for the current test case."""
254
if details and 'benchtime' in details:
255
return float(''.join(details['benchtime'].iter_bytes()))
256
197
return getattr(testCase, "_benchtime", None)
258
199
def _elapsedTestTimeString(self):
597
580
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
621
584
self.stream = unittest._WritelnDecorator(stream)
622
585
self.descriptions = descriptions
623
586
self.verbosity = verbosity
624
587
self._bench_history = bench_history
588
self.list_only = list_only
625
589
self._strict = strict
626
self._result_decorators = result_decorators or []
628
591
def run(self, test):
629
592
"Run the given test case or test suite."
593
startTime = time.time()
630
594
if self.verbosity == 1:
631
595
result_class = TextTestResult
632
596
elif self.verbosity >= 2:
633
597
result_class = VerboseTestResult
634
original_result = result_class(self.stream,
598
result = result_class(self.stream,
635
599
self.descriptions,
637
601
bench_history=self._bench_history,
638
602
strict=self._strict,
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
604
result.stop_early = self.stop_on_failure
605
result.report_starting()
607
if self.verbosity >= 2:
608
self.stream.writeln("Listing tests only ...\n")
610
for t in iter_suite_tests(test):
611
self.stream.writeln("%s" % (t.id()))
620
if isinstance(test, testtools.ConcurrentTestSuite):
621
# We need to catch bzr specific behaviors
622
test.run(BZRTransformingResult(result))
625
run = result.testsRun
627
stopTime = time.time()
628
timeTaken = stopTime - startTime
630
self.stream.writeln(result.separator2)
631
self.stream.writeln("%s %d test%s in %.3fs" % (actionTaken,
632
run, run != 1 and "s" or "", timeTaken))
633
self.stream.writeln()
634
if not result.wasSuccessful():
635
self.stream.write("FAILED (")
636
failed, errored = map(len, (result.failures, result.errors))
638
self.stream.write("failures=%d" % failed)
640
if failed: self.stream.write(", ")
641
self.stream.write("errors=%d" % errored)
642
if result.known_failure_count:
643
if failed or errored: self.stream.write(", ")
644
self.stream.write("known_failure_count=%d" %
645
result.known_failure_count)
646
self.stream.writeln(")")
648
if result.known_failure_count:
649
self.stream.writeln("OK (known_failures=%d)" %
650
result.known_failure_count)
652
self.stream.writeln("OK")
653
if result.skip_count > 0:
654
skipped = result.skip_count
655
self.stream.writeln('%d test%s skipped' %
656
(skipped, skipped != 1 and "s" or ""))
657
if result.unsupported:
658
for feature, count in sorted(result.unsupported.items()):
659
self.stream.writeln("Missing feature '%s' skipped %d tests." %
656
665
def iter_suite_tests(suite):
940
929
def _lock_broken(self, result):
941
930
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 = 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 = 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.")
1070
932
def _ndiff_strings(self, a, b):
1071
933
"""Return ndiff between two strings containing lines.
1575
1422
def _do_skip(self, result, reason):
1576
1423
addSkip = getattr(result, 'addSkip', None)
1577
1424
if not callable(addSkip):
1578
result.addSuccess(result)
1425
result.addError(self, sys.exc_info())
1580
1427
addSkip(self, reason)
1583
def _do_known_failure(self, result, e):
1584
err = sys.exc_info()
1585
addExpectedFailure = getattr(result, 'addExpectedFailure', None)
1586
if addExpectedFailure is not None:
1587
addExpectedFailure(self, err)
1589
result.addSuccess(self)
1592
def _do_not_applicable(self, result, e):
1594
reason = 'No reason given'
1597
addNotApplicable = getattr(result, 'addNotApplicable', None)
1598
if addNotApplicable is not None:
1599
result.addNotApplicable(self, reason)
1601
self._do_skip(result, reason)
1604
def _do_unsupported_or_skip(self, result, e):
1606
addNotSupported = getattr(result, 'addNotSupported', None)
1607
if addNotSupported is not None:
1608
result.addNotSupported(self, reason)
1610
self._do_skip(result, reason)
1429
def run(self, result=None):
1430
if result is None: result = self.defaultTestResult()
1431
for feature in getattr(self, '_test_needs_features', []):
1432
if not feature.available():
1433
result.startTest(self)
1434
if getattr(result, 'addNotSupported', None):
1435
result.addNotSupported(self, feature)
1437
result.addSuccess(self)
1438
result.stopTest(self)
1442
result.startTest(self)
1443
absent_attr = object()
1445
method_name = getattr(self, '_testMethodName', absent_attr)
1446
if method_name is absent_attr:
1448
method_name = getattr(self, '_TestCase__testMethodName')
1449
testMethod = getattr(self, method_name)
1453
if not self._bzr_test_setUp_run:
1455
"test setUp did not invoke "
1456
"bzrlib.tests.TestCase's setUp")
1457
except KeyboardInterrupt:
1460
except TestSkipped, e:
1461
self._do_skip(result, e.args[0])
1465
result.addError(self, sys.exc_info())
1473
except self.failureException:
1474
result.addFailure(self, sys.exc_info())
1475
except TestSkipped, e:
1477
reason = "No reason given."
1480
self._do_skip(result, reason)
1481
except KeyboardInterrupt:
1485
result.addError(self, sys.exc_info())
1489
if not self._bzr_test_tearDown_run:
1491
"test tearDown did not invoke "
1492
"bzrlib.tests.TestCase's tearDown")
1493
except KeyboardInterrupt:
1497
result.addError(self, sys.exc_info())
1500
if ok: result.addSuccess(self)
1502
result.stopTest(self)
1504
except TestNotApplicable:
1505
# Not moved from the result [yet].
1508
except KeyboardInterrupt:
1513
for attr_name in self.attrs_to_keep:
1514
if attr_name in self.__dict__:
1515
saved_attrs[attr_name] = self.__dict__[attr_name]
1516
self.__dict__ = saved_attrs
1520
self._log_contents = ''
1521
self._bzr_test_tearDown_run = True
1522
unittest.TestCase.tearDown(self)
1612
1524
def time(self, callable, *args, **kwargs):
1613
1525
"""Run callable and accrue the time it takes to the benchmark time.
3575
3420
test_prefix_alias_registry.register('bp', 'bzrlib.plugins')
3578
def _test_suite_testmod_names():
3579
"""Return the standard list of test module names to test."""
3582
'bzrlib.tests.blackbox',
3583
'bzrlib.tests.commands',
3584
'bzrlib.tests.per_branch',
3585
'bzrlib.tests.per_bzrdir',
3586
'bzrlib.tests.per_foreign_vcs',
3587
'bzrlib.tests.per_interrepository',
3588
'bzrlib.tests.per_intertree',
3589
'bzrlib.tests.per_inventory',
3590
'bzrlib.tests.per_interbranch',
3591
'bzrlib.tests.per_lock',
3592
'bzrlib.tests.per_merger',
3593
'bzrlib.tests.per_transport',
3594
'bzrlib.tests.per_tree',
3595
'bzrlib.tests.per_pack_repository',
3596
'bzrlib.tests.per_repository',
3597
'bzrlib.tests.per_repository_chk',
3598
'bzrlib.tests.per_repository_reference',
3599
'bzrlib.tests.per_uifactory',
3600
'bzrlib.tests.per_versionedfile',
3601
'bzrlib.tests.per_workingtree',
3602
'bzrlib.tests.test__annotator',
3603
'bzrlib.tests.test__bencode',
3604
'bzrlib.tests.test__chk_map',
3605
'bzrlib.tests.test__dirstate_helpers',
3606
'bzrlib.tests.test__groupcompress',
3607
'bzrlib.tests.test__known_graph',
3608
'bzrlib.tests.test__rio',
3609
'bzrlib.tests.test__simple_set',
3610
'bzrlib.tests.test__static_tuple',
3611
'bzrlib.tests.test__walkdirs_win32',
3612
'bzrlib.tests.test_ancestry',
3613
'bzrlib.tests.test_annotate',
3614
'bzrlib.tests.test_api',
3615
'bzrlib.tests.test_atomicfile',
3616
'bzrlib.tests.test_bad_files',
3617
'bzrlib.tests.test_bisect_multi',
3618
'bzrlib.tests.test_branch',
3619
'bzrlib.tests.test_branchbuilder',
3620
'bzrlib.tests.test_btree_index',
3621
'bzrlib.tests.test_bugtracker',
3622
'bzrlib.tests.test_bundle',
3623
'bzrlib.tests.test_bzrdir',
3624
'bzrlib.tests.test__chunks_to_lines',
3625
'bzrlib.tests.test_cache_utf8',
3626
'bzrlib.tests.test_chk_map',
3627
'bzrlib.tests.test_chk_serializer',
3628
'bzrlib.tests.test_chunk_writer',
3629
'bzrlib.tests.test_clean_tree',
3630
'bzrlib.tests.test_cleanup',
3631
'bzrlib.tests.test_cmdline',
3632
'bzrlib.tests.test_commands',
3633
'bzrlib.tests.test_commit',
3634
'bzrlib.tests.test_commit_merge',
3635
'bzrlib.tests.test_config',
3636
'bzrlib.tests.test_conflicts',
3637
'bzrlib.tests.test_counted_lock',
3638
'bzrlib.tests.test_crash',
3639
'bzrlib.tests.test_decorators',
3640
'bzrlib.tests.test_delta',
3641
'bzrlib.tests.test_debug',
3642
'bzrlib.tests.test_deprecated_graph',
3643
'bzrlib.tests.test_diff',
3644
'bzrlib.tests.test_directory_service',
3645
'bzrlib.tests.test_dirstate',
3646
'bzrlib.tests.test_email_message',
3647
'bzrlib.tests.test_eol_filters',
3648
'bzrlib.tests.test_errors',
3649
'bzrlib.tests.test_export',
3650
'bzrlib.tests.test_extract',
3651
'bzrlib.tests.test_fetch',
3652
'bzrlib.tests.test_fifo_cache',
3653
'bzrlib.tests.test_filters',
3654
'bzrlib.tests.test_ftp_transport',
3655
'bzrlib.tests.test_foreign',
3656
'bzrlib.tests.test_generate_docs',
3657
'bzrlib.tests.test_generate_ids',
3658
'bzrlib.tests.test_globbing',
3659
'bzrlib.tests.test_gpg',
3660
'bzrlib.tests.test_graph',
3661
'bzrlib.tests.test_groupcompress',
3662
'bzrlib.tests.test_hashcache',
3663
'bzrlib.tests.test_help',
3664
'bzrlib.tests.test_hooks',
3665
'bzrlib.tests.test_http',
3666
'bzrlib.tests.test_http_response',
3667
'bzrlib.tests.test_https_ca_bundle',
3668
'bzrlib.tests.test_identitymap',
3669
'bzrlib.tests.test_ignores',
3670
'bzrlib.tests.test_index',
3671
'bzrlib.tests.test_import_tariff',
3672
'bzrlib.tests.test_info',
3673
'bzrlib.tests.test_inv',
3674
'bzrlib.tests.test_inventory_delta',
3675
'bzrlib.tests.test_knit',
3676
'bzrlib.tests.test_lazy_import',
3677
'bzrlib.tests.test_lazy_regex',
3678
'bzrlib.tests.test_lock',
3679
'bzrlib.tests.test_lockable_files',
3680
'bzrlib.tests.test_lockdir',
3681
'bzrlib.tests.test_log',
3682
'bzrlib.tests.test_lru_cache',
3683
'bzrlib.tests.test_lsprof',
3684
'bzrlib.tests.test_mail_client',
3685
'bzrlib.tests.test_memorytree',
3686
'bzrlib.tests.test_merge',
3687
'bzrlib.tests.test_merge3',
3688
'bzrlib.tests.test_merge_core',
3689
'bzrlib.tests.test_merge_directive',
3690
'bzrlib.tests.test_missing',
3691
'bzrlib.tests.test_msgeditor',
3692
'bzrlib.tests.test_multiparent',
3693
'bzrlib.tests.test_mutabletree',
3694
'bzrlib.tests.test_nonascii',
3695
'bzrlib.tests.test_options',
3696
'bzrlib.tests.test_osutils',
3697
'bzrlib.tests.test_osutils_encodings',
3698
'bzrlib.tests.test_pack',
3699
'bzrlib.tests.test_patch',
3700
'bzrlib.tests.test_patches',
3701
'bzrlib.tests.test_permissions',
3702
'bzrlib.tests.test_plugins',
3703
'bzrlib.tests.test_progress',
3704
'bzrlib.tests.test_read_bundle',
3705
'bzrlib.tests.test_reconcile',
3706
'bzrlib.tests.test_reconfigure',
3707
'bzrlib.tests.test_registry',
3708
'bzrlib.tests.test_remote',
3709
'bzrlib.tests.test_rename_map',
3710
'bzrlib.tests.test_repository',
3711
'bzrlib.tests.test_revert',
3712
'bzrlib.tests.test_revision',
3713
'bzrlib.tests.test_revisionspec',
3714
'bzrlib.tests.test_revisiontree',
3715
'bzrlib.tests.test_rio',
3716
'bzrlib.tests.test_rules',
3717
'bzrlib.tests.test_sampler',
3718
'bzrlib.tests.test_script',
3719
'bzrlib.tests.test_selftest',
3720
'bzrlib.tests.test_serializer',
3721
'bzrlib.tests.test_setup',
3722
'bzrlib.tests.test_sftp_transport',
3723
'bzrlib.tests.test_shelf',
3724
'bzrlib.tests.test_shelf_ui',
3725
'bzrlib.tests.test_smart',
3726
'bzrlib.tests.test_smart_add',
3727
'bzrlib.tests.test_smart_request',
3728
'bzrlib.tests.test_smart_transport',
3729
'bzrlib.tests.test_smtp_connection',
3730
'bzrlib.tests.test_source',
3731
'bzrlib.tests.test_ssh_transport',
3732
'bzrlib.tests.test_status',
3733
'bzrlib.tests.test_store',
3734
'bzrlib.tests.test_strace',
3735
'bzrlib.tests.test_subsume',
3736
'bzrlib.tests.test_switch',
3737
'bzrlib.tests.test_symbol_versioning',
3738
'bzrlib.tests.test_tag',
3739
'bzrlib.tests.test_testament',
3740
'bzrlib.tests.test_textfile',
3741
'bzrlib.tests.test_textmerge',
3742
'bzrlib.tests.test_timestamp',
3743
'bzrlib.tests.test_trace',
3744
'bzrlib.tests.test_transactions',
3745
'bzrlib.tests.test_transform',
3746
'bzrlib.tests.test_transport',
3747
'bzrlib.tests.test_transport_log',
3748
'bzrlib.tests.test_tree',
3749
'bzrlib.tests.test_treebuilder',
3750
'bzrlib.tests.test_tsort',
3751
'bzrlib.tests.test_tuned_gzip',
3752
'bzrlib.tests.test_ui',
3753
'bzrlib.tests.test_uncommit',
3754
'bzrlib.tests.test_upgrade',
3755
'bzrlib.tests.test_upgrade_stacked',
3756
'bzrlib.tests.test_urlutils',
3757
'bzrlib.tests.test_version',
3758
'bzrlib.tests.test_version_info',
3759
'bzrlib.tests.test_weave',
3760
'bzrlib.tests.test_whitebox',
3761
'bzrlib.tests.test_win32utils',
3762
'bzrlib.tests.test_workingtree',
3763
'bzrlib.tests.test_workingtree_4',
3764
'bzrlib.tests.test_wsgi',
3765
'bzrlib.tests.test_xml',
3769
def _test_suite_modules_to_doctest():
3770
"""Return the list of modules to doctest."""
3773
'bzrlib.branchbuilder',
3774
'bzrlib.decorators',
3777
'bzrlib.iterablefile',
3781
'bzrlib.symbol_versioning',
3784
'bzrlib.version_info_formats.format_custom',
3788
3423
def test_suite(keep_only=None, starting_with=None):
3789
3424
"""Build and return TestSuite for the whole of bzrlib.
3796
3431
This function can be replaced if you need to change the default test
3797
3432
suite on a global basis, but it is not encouraged.
3436
'bzrlib.tests.blackbox',
3437
'bzrlib.tests.commands',
3438
'bzrlib.tests.per_branch',
3439
'bzrlib.tests.per_bzrdir',
3440
'bzrlib.tests.per_interrepository',
3441
'bzrlib.tests.per_intertree',
3442
'bzrlib.tests.per_inventory',
3443
'bzrlib.tests.per_interbranch',
3444
'bzrlib.tests.per_lock',
3445
'bzrlib.tests.per_transport',
3446
'bzrlib.tests.per_tree',
3447
'bzrlib.tests.per_pack_repository',
3448
'bzrlib.tests.per_repository',
3449
'bzrlib.tests.per_repository_chk',
3450
'bzrlib.tests.per_repository_reference',
3451
'bzrlib.tests.per_versionedfile',
3452
'bzrlib.tests.per_workingtree',
3453
'bzrlib.tests.test__annotator',
3454
'bzrlib.tests.test__chk_map',
3455
'bzrlib.tests.test__dirstate_helpers',
3456
'bzrlib.tests.test__groupcompress',
3457
'bzrlib.tests.test__known_graph',
3458
'bzrlib.tests.test__rio',
3459
'bzrlib.tests.test__walkdirs_win32',
3460
'bzrlib.tests.test_ancestry',
3461
'bzrlib.tests.test_annotate',
3462
'bzrlib.tests.test_api',
3463
'bzrlib.tests.test_atomicfile',
3464
'bzrlib.tests.test_bad_files',
3465
'bzrlib.tests.test_bencode',
3466
'bzrlib.tests.test_bisect_multi',
3467
'bzrlib.tests.test_branch',
3468
'bzrlib.tests.test_branchbuilder',
3469
'bzrlib.tests.test_btree_index',
3470
'bzrlib.tests.test_bugtracker',
3471
'bzrlib.tests.test_bundle',
3472
'bzrlib.tests.test_bzrdir',
3473
'bzrlib.tests.test__chunks_to_lines',
3474
'bzrlib.tests.test_cache_utf8',
3475
'bzrlib.tests.test_chk_map',
3476
'bzrlib.tests.test_chk_serializer',
3477
'bzrlib.tests.test_chunk_writer',
3478
'bzrlib.tests.test_clean_tree',
3479
'bzrlib.tests.test_commands',
3480
'bzrlib.tests.test_commit',
3481
'bzrlib.tests.test_commit_merge',
3482
'bzrlib.tests.test_config',
3483
'bzrlib.tests.test_conflicts',
3484
'bzrlib.tests.test_counted_lock',
3485
'bzrlib.tests.test_crash',
3486
'bzrlib.tests.test_decorators',
3487
'bzrlib.tests.test_delta',
3488
'bzrlib.tests.test_debug',
3489
'bzrlib.tests.test_deprecated_graph',
3490
'bzrlib.tests.test_diff',
3491
'bzrlib.tests.test_directory_service',
3492
'bzrlib.tests.test_dirstate',
3493
'bzrlib.tests.test_email_message',
3494
'bzrlib.tests.test_eol_filters',
3495
'bzrlib.tests.test_errors',
3496
'bzrlib.tests.test_export',
3497
'bzrlib.tests.test_extract',
3498
'bzrlib.tests.test_fetch',
3499
'bzrlib.tests.test_fifo_cache',
3500
'bzrlib.tests.test_filters',
3501
'bzrlib.tests.test_ftp_transport',
3502
'bzrlib.tests.test_foreign',
3503
'bzrlib.tests.test_generate_docs',
3504
'bzrlib.tests.test_generate_ids',
3505
'bzrlib.tests.test_globbing',
3506
'bzrlib.tests.test_gpg',
3507
'bzrlib.tests.test_graph',
3508
'bzrlib.tests.test_groupcompress',
3509
'bzrlib.tests.test_hashcache',
3510
'bzrlib.tests.test_help',
3511
'bzrlib.tests.test_hooks',
3512
'bzrlib.tests.test_http',
3513
'bzrlib.tests.test_http_response',
3514
'bzrlib.tests.test_https_ca_bundle',
3515
'bzrlib.tests.test_identitymap',
3516
'bzrlib.tests.test_ignores',
3517
'bzrlib.tests.test_index',
3518
'bzrlib.tests.test_info',
3519
'bzrlib.tests.test_inv',
3520
'bzrlib.tests.test_inventory_delta',
3521
'bzrlib.tests.test_knit',
3522
'bzrlib.tests.test_lazy_import',
3523
'bzrlib.tests.test_lazy_regex',
3524
'bzrlib.tests.test_lock',
3525
'bzrlib.tests.test_lockable_files',
3526
'bzrlib.tests.test_lockdir',
3527
'bzrlib.tests.test_log',
3528
'bzrlib.tests.test_lru_cache',
3529
'bzrlib.tests.test_lsprof',
3530
'bzrlib.tests.test_mail_client',
3531
'bzrlib.tests.test_memorytree',
3532
'bzrlib.tests.test_merge',
3533
'bzrlib.tests.test_merge3',
3534
'bzrlib.tests.test_merge_core',
3535
'bzrlib.tests.test_merge_directive',
3536
'bzrlib.tests.test_missing',
3537
'bzrlib.tests.test_msgeditor',
3538
'bzrlib.tests.test_multiparent',
3539
'bzrlib.tests.test_mutabletree',
3540
'bzrlib.tests.test_nonascii',
3541
'bzrlib.tests.test_options',
3542
'bzrlib.tests.test_osutils',
3543
'bzrlib.tests.test_osutils_encodings',
3544
'bzrlib.tests.test_pack',
3545
'bzrlib.tests.test_patch',
3546
'bzrlib.tests.test_patches',
3547
'bzrlib.tests.test_permissions',
3548
'bzrlib.tests.test_plugins',
3549
'bzrlib.tests.test_progress',
3550
'bzrlib.tests.test_read_bundle',
3551
'bzrlib.tests.test_reconcile',
3552
'bzrlib.tests.test_reconfigure',
3553
'bzrlib.tests.test_registry',
3554
'bzrlib.tests.test_remote',
3555
'bzrlib.tests.test_rename_map',
3556
'bzrlib.tests.test_repository',
3557
'bzrlib.tests.test_revert',
3558
'bzrlib.tests.test_revision',
3559
'bzrlib.tests.test_revisionspec',
3560
'bzrlib.tests.test_revisiontree',
3561
'bzrlib.tests.test_rio',
3562
'bzrlib.tests.test_rules',
3563
'bzrlib.tests.test_sampler',
3564
'bzrlib.tests.test_selftest',
3565
'bzrlib.tests.test_serializer',
3566
'bzrlib.tests.test_setup',
3567
'bzrlib.tests.test_sftp_transport',
3568
'bzrlib.tests.test_shelf',
3569
'bzrlib.tests.test_shelf_ui',
3570
'bzrlib.tests.test_smart',
3571
'bzrlib.tests.test_smart_add',
3572
'bzrlib.tests.test_smart_request',
3573
'bzrlib.tests.test_smart_transport',
3574
'bzrlib.tests.test_smtp_connection',
3575
'bzrlib.tests.test_source',
3576
'bzrlib.tests.test_ssh_transport',
3577
'bzrlib.tests.test_status',
3578
'bzrlib.tests.test_store',
3579
'bzrlib.tests.test_strace',
3580
'bzrlib.tests.test_subsume',
3581
'bzrlib.tests.test_switch',
3582
'bzrlib.tests.test_symbol_versioning',
3583
'bzrlib.tests.test_tag',
3584
'bzrlib.tests.test_testament',
3585
'bzrlib.tests.test_textfile',
3586
'bzrlib.tests.test_textmerge',
3587
'bzrlib.tests.test_timestamp',
3588
'bzrlib.tests.test_trace',
3589
'bzrlib.tests.test_transactions',
3590
'bzrlib.tests.test_transform',
3591
'bzrlib.tests.test_transport',
3592
'bzrlib.tests.test_transport_log',
3593
'bzrlib.tests.test_tree',
3594
'bzrlib.tests.test_treebuilder',
3595
'bzrlib.tests.test_tsort',
3596
'bzrlib.tests.test_tuned_gzip',
3597
'bzrlib.tests.test_ui',
3598
'bzrlib.tests.test_uncommit',
3599
'bzrlib.tests.test_upgrade',
3600
'bzrlib.tests.test_upgrade_stacked',
3601
'bzrlib.tests.test_urlutils',
3602
'bzrlib.tests.test_version',
3603
'bzrlib.tests.test_version_info',
3604
'bzrlib.tests.test_weave',
3605
'bzrlib.tests.test_whitebox',
3606
'bzrlib.tests.test_win32utils',
3607
'bzrlib.tests.test_workingtree',
3608
'bzrlib.tests.test_workingtree_4',
3609
'bzrlib.tests.test_wsgi',
3610
'bzrlib.tests.test_xml',
3800
3613
loader = TestUtil.TestLoader()
4135
3920
UnicodeFilenameFeature = _UnicodeFilenameFeature()
4138
class _CompatabilityThunkFeature(Feature):
4139
"""This feature is just a thunk to another feature.
4141
It issues a deprecation warning if it is accessed, to let you know that you
4142
should really use a different feature.
4145
def __init__(self, dep_version, module, name,
4146
replacement_name, replacement_module=None):
4147
super(_CompatabilityThunkFeature, self).__init__()
4148
self._module = module
4149
if replacement_module is None:
4150
replacement_module = module
4151
self._replacement_module = replacement_module
4153
self._replacement_name = replacement_name
4154
self._dep_version = dep_version
4155
self._feature = None
4158
if self._feature is None:
4159
depr_msg = self._dep_version % ('%s.%s'
4160
% (self._module, self._name))
4161
use_msg = ' Use %s.%s instead.' % (self._replacement_module,
4162
self._replacement_name)
4163
symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning)
4164
# Import the new feature and use it as a replacement for the
4166
mod = __import__(self._replacement_module, {}, {},
4167
[self._replacement_name])
4168
self._feature = getattr(mod, self._replacement_name)
4172
return self._feature._probe()
4175
class ModuleAvailableFeature(Feature):
4176
"""This is a feature than describes a module we want to be available.
4178
Declare the name of the module in __init__(), and then after probing, the
4179
module will be available as 'self.module'.
4181
:ivar module: The module if it is available, else None.
4184
def __init__(self, module_name):
4185
super(ModuleAvailableFeature, self).__init__()
4186
self.module_name = module_name
4190
self._module = __import__(self.module_name, {}, {}, [''])
4197
if self.available(): # Make sure the probe has been done
4201
def feature_name(self):
4202
return self.module_name
4205
# This is kept here for compatibility, it is recommended to use
4206
# 'bzrlib.tests.feature.paramiko' instead
4207
ParamikoFeature = _CompatabilityThunkFeature(
4208
deprecated_in((2,1,0)),
4209
'bzrlib.tests.features', 'ParamikoFeature', 'paramiko')
4212
3923
def probe_unicode_in_user_encoding():
4213
3924
"""Try to encode several unicode strings to use in unicode-aware tests.
4214
3925
Return first successfull match.