1507
1739
:returns: The actual attr value.
1509
value = getattr(obj, attr_name)
1510
1741
# The actual value is captured by the call below
1511
self.addCleanup(setattr, obj, attr_name, value)
1742
value = getattr(obj, attr_name, _unitialized_attr)
1743
if value is _unitialized_attr:
1744
# When the test completes, the attribute should not exist, but if
1745
# we aren't setting a value, we don't need to do anything.
1746
if new is not _unitialized_attr:
1747
self.addCleanup(delattr, obj, attr_name)
1749
self.addCleanup(setattr, obj, attr_name, value)
1512
1750
if new is not _unitialized_attr:
1513
1751
setattr(obj, attr_name, new)
1754
def overrideEnv(self, name, new):
1755
"""Set an environment variable, and reset it after the test.
1757
:param name: The environment variable name.
1759
:param new: The value to set the variable to. If None, the
1760
variable is deleted from the environment.
1762
:returns: The actual variable value.
1764
value = osutils.set_or_unset_env(name, new)
1765
self.addCleanup(osutils.set_or_unset_env, name, value)
1768
def recordCalls(self, obj, attr_name):
1769
"""Monkeypatch in a wrapper that will record calls.
1771
The monkeypatch is automatically removed when the test concludes.
1773
:param obj: The namespace holding the reference to be replaced;
1774
typically a module, class, or object.
1775
:param attr_name: A string for the name of the attribute to patch.
1776
:returns: A list that will be extended with one item every time the
1777
function is called, with a tuple of (args, kwargs).
1781
def decorator(*args, **kwargs):
1782
calls.append((args, kwargs))
1783
return orig(*args, **kwargs)
1784
orig = self.overrideAttr(obj, attr_name, decorator)
1516
1787
def _cleanEnvironment(self):
1518
'BZR_HOME': None, # Don't inherit BZR_HOME to all the tests.
1519
'HOME': os.getcwd(),
1520
# bzr now uses the Win32 API and doesn't rely on APPDATA, but the
1521
# tests do check our impls match APPDATA
1522
'BZR_EDITOR': None, # test_msgeditor manipulates this variable
1526
'BZREMAIL': None, # may still be present in the environment
1528
'BZR_PROGRESS_BAR': None,
1530
'BZR_PLUGIN_PATH': None,
1531
'BZR_DISABLE_PLUGINS': None,
1532
'BZR_PLUGINS_AT': None,
1533
'BZR_CONCURRENCY': None,
1534
# Make sure that any text ui tests are consistent regardless of
1535
# the environment the test case is run in; you may want tests that
1536
# test other combinations. 'dumb' is a reasonable guess for tests
1537
# going to a pipe or a StringIO.
1541
'BZR_COLUMNS': '80',
1543
'SSH_AUTH_SOCK': None,
1547
'https_proxy': None,
1548
'HTTPS_PROXY': None,
1553
# Nobody cares about ftp_proxy, FTP_PROXY AFAIK. So far at
1554
# least. If you do (care), please update this comment
1558
'BZR_REMOTE_PATH': None,
1559
# Generally speaking, we don't want apport reporting on crashes in
1560
# the test envirnoment unless we're specifically testing apport,
1561
# so that it doesn't leak into the real system environment. We
1562
# use an env var so it propagates to subprocesses.
1563
'APPORT_DISABLE': '1',
1566
self.addCleanup(self._restoreEnvironment)
1567
for name, value in new_env.iteritems():
1568
self._captureVar(name, value)
1570
def _captureVar(self, name, newvalue):
1571
"""Set an environment variable, and reset it when finished."""
1572
self._old_env[name] = osutils.set_or_unset_env(name, newvalue)
1574
def _restoreEnvironment(self):
1575
for name, value in self._old_env.iteritems():
1576
osutils.set_or_unset_env(name, value)
1788
for name, value in isolated_environ.items():
1789
self.overrideEnv(name, value)
1578
1791
def _restoreHooks(self):
1579
1792
for klass, (name, hooks) in self._preserved_hooks.items():
1580
1793
setattr(klass, name, hooks)
1794
self._preserved_hooks.clear()
1795
breezy.hooks._lazy_hooks = self._preserved_lazy_hooks
1796
self._preserved_lazy_hooks.clear()
1582
1798
def knownFailure(self, reason):
1583
"""This test has failed for some known reason."""
1584
raise KnownFailure(reason)
1799
"""Declare that this test fails for a known reason
1801
Tests that are known to fail should generally be using expectedFailure
1802
with an appropriate reverse assertion if a change could cause the test
1803
to start passing. Conversely if the test has no immediate prospect of
1804
succeeding then using skip is more suitable.
1806
When this method is called while an exception is being handled, that
1807
traceback will be used, otherwise a new exception will be thrown to
1808
provide one but won't be reported.
1810
self._add_reason(reason)
1812
exc_info = sys.exc_info()
1813
if exc_info != (None, None, None):
1814
self._report_traceback(exc_info)
1817
raise self.failureException(reason)
1818
except self.failureException:
1819
exc_info = sys.exc_info()
1820
# GZ 02-08-2011: Maybe cleanup this err.exc_info attribute too?
1821
raise testtools.testcase._ExpectedFailure(exc_info)
1825
def _suppress_log(self):
1826
"""Remove the log info from details."""
1827
self.discardDetail('log')
1586
1829
def _do_skip(self, result, reason):
1830
self._suppress_log()
1587
1831
addSkip = getattr(result, 'addSkip', None)
1588
1832
if not callable(addSkip):
1589
1833
result.addSuccess(result)
1591
addSkip(self, reason)
1835
addSkip(self, str(reason))
1594
1838
def _do_known_failure(self, result, e):
1839
self._suppress_log()
1595
1840
err = sys.exc_info()
1596
1841
addExpectedFailure = getattr(result, 'addExpectedFailure', None)
1597
1842
if addExpectedFailure is not None:
1779
1957
os.chdir(working_dir)
1783
result = self.apply_redirected(ui.ui_factory.stdin,
1961
result = self.apply_redirected(
1962
ui.ui_factory.stdin,
1784
1963
stdout, stderr,
1785
bzrlib.commands.run_bzr_catch_user_errors,
1964
_mod_commands.run_bzr_catch_user_errors,
1787
except KeyboardInterrupt:
1788
# Reraise KeyboardInterrupt with contents of redirected stdout
1789
# and stderr as arguments, for tests which are interested in
1790
# stdout and stderr and are expecting the exception.
1791
out = stdout.getvalue()
1792
err = stderr.getvalue()
1794
self.log('output:\n%r', out)
1796
self.log('errors:\n%r', err)
1797
raise KeyboardInterrupt(out, err)
1799
logger.removeHandler(handler)
1800
1967
ui.ui_factory = old_ui_factory
1801
1968
if cwd is not None:
1804
out = stdout.getvalue()
1805
err = stderr.getvalue()
1807
self.log('output:\n%r', out)
1809
self.log('errors:\n%r', err)
1810
if retcode is not None:
1811
self.assertEquals(retcode, result,
1812
message='Unexpected return code')
1813
return result, out, err
1815
def run_bzr(self, args, retcode=0, encoding=None, stdin=None,
1816
working_dir=None, error_regexes=[], output_encoding=None):
1817
"""Invoke bzr, as if it were run from the command line.
1819
The argument list should not include the bzr program name - the
1820
first argument is normally the bzr command. Arguments may be
1821
passed in three ways:
1823
1- A list of strings, eg ["commit", "a"]. This is recommended
1824
when the command contains whitespace or metacharacters, or
1825
is built up at run time.
1827
2- A single string, eg "add a". This is the most convenient
1828
for hardcoded commands.
1830
This runs bzr through the interface that catches and reports
1831
errors, and with logging set to something approximating the
1832
default, so that error reporting can be checked.
1834
This should be the main method for tests that want to exercise the
1835
overall behavior of the bzr application (rather than a unit test
1836
or a functional test of the library.)
1838
This sends the stdout/stderr results into the test's log,
1839
where it may be useful for debugging. See also run_captured.
1841
:keyword stdin: A string to be used as stdin for the command.
1842
:keyword retcode: The status code the command should return;
1844
:keyword working_dir: The directory to run the command in
1845
:keyword error_regexes: A list of expected error messages. If
1846
specified they must be seen in the error output of the command.
1848
retcode, out, err = self._run_bzr_autosplit(
1853
working_dir=working_dir,
1973
def run_bzr_raw(self, args, retcode=0, stdin=None, encoding=None,
1974
working_dir=None, error_regexes=[]):
1975
"""Invoke brz, as if it were run from the command line.
1977
The argument list should not include the brz program name - the
1978
first argument is normally the brz command. Arguments may be
1979
passed in three ways:
1981
1- A list of strings, eg ["commit", "a"]. This is recommended
1982
when the command contains whitespace or metacharacters, or
1983
is built up at run time.
1985
2- A single string, eg "add a". This is the most convenient
1986
for hardcoded commands.
1988
This runs brz through the interface that catches and reports
1989
errors, and with logging set to something approximating the
1990
default, so that error reporting can be checked.
1992
This should be the main method for tests that want to exercise the
1993
overall behavior of the brz application (rather than a unit test
1994
or a functional test of the library.)
1996
This sends the stdout/stderr results into the test's log,
1997
where it may be useful for debugging. See also run_captured.
1999
:keyword stdin: A string to be used as stdin for the command.
2000
:keyword retcode: The status code the command should return;
2002
:keyword working_dir: The directory to run the command in
2003
:keyword error_regexes: A list of expected error messages. If
2004
specified they must be seen in the error output of the command.
2006
if isinstance(args, string_types):
2007
args = shlex.split(args)
2009
if encoding is None:
2010
encoding = osutils.get_user_encoding()
2012
if sys.version_info[0] == 2:
2013
wrapped_stdout = stdout = ui_testing.BytesIOWithEncoding()
2014
wrapped_stderr = stderr = ui_testing.BytesIOWithEncoding()
2015
stdout.encoding = stderr.encoding = encoding
2017
# FIXME: don't call into logging here
2018
handler = trace.EncodedStreamHandler(
2019
stderr, errors="replace")
2023
wrapped_stdout = TextIOWrapper(stdout, encoding)
2024
wrapped_stderr = TextIOWrapper(stderr, encoding)
2025
handler = logging.StreamHandler(wrapped_stderr)
2026
handler.setLevel(logging.INFO)
2028
logger = logging.getLogger('')
2029
logger.addHandler(handler)
2031
result = self._run_bzr_core(
2032
args, encoding=encoding, stdin=stdin, stdout=wrapped_stdout,
2033
stderr=wrapped_stderr, working_dir=working_dir,
2036
logger.removeHandler(handler)
2039
wrapped_stdout.flush()
2040
wrapped_stderr.flush()
2042
out = stdout.getvalue()
2043
err = stderr.getvalue()
2045
self.log('output:\n%r', out)
2047
self.log('errors:\n%r', err)
2048
if retcode is not None:
2049
self.assertEqual(retcode, result,
2050
message='Unexpected return code')
2051
self.assertIsInstance(error_regexes, (list, tuple))
2052
for regex in error_regexes:
2053
self.assertContainsRe(err, regex)
2056
def run_bzr(self, args, retcode=0, stdin=None, encoding=None,
2057
working_dir=None, error_regexes=[]):
2058
"""Invoke brz, as if it were run from the command line.
2060
The argument list should not include the brz program name - the
2061
first argument is normally the brz command. Arguments may be
2062
passed in three ways:
2064
1- A list of strings, eg ["commit", "a"]. This is recommended
2065
when the command contains whitespace or metacharacters, or
2066
is built up at run time.
2068
2- A single string, eg "add a". This is the most convenient
2069
for hardcoded commands.
2071
This runs brz through the interface that catches and reports
2072
errors, and with logging set to something approximating the
2073
default, so that error reporting can be checked.
2075
This should be the main method for tests that want to exercise the
2076
overall behavior of the brz application (rather than a unit test
2077
or a functional test of the library.)
2079
This sends the stdout/stderr results into the test's log,
2080
where it may be useful for debugging. See also run_captured.
2082
:keyword stdin: A string to be used as stdin for the command.
2083
:keyword retcode: The status code the command should return;
2085
:keyword working_dir: The directory to run the command in
2086
:keyword error_regexes: A list of expected error messages. If
2087
specified they must be seen in the error output of the command.
2089
if isinstance(args, string_types):
2090
args = shlex.split(args)
2092
if encoding is None:
2093
encoding = osutils.get_user_encoding()
2095
if sys.version_info[0] == 2:
2096
stdout = ui_testing.BytesIOWithEncoding()
2097
stderr = ui_testing.BytesIOWithEncoding()
2098
stdout.encoding = stderr.encoding = encoding
2099
# FIXME: don't call into logging here
2100
handler = trace.EncodedStreamHandler(
2101
stderr, errors="replace")
2103
stdout = ui_testing.StringIOWithEncoding()
2104
stderr = ui_testing.StringIOWithEncoding()
2105
stdout.encoding = stderr.encoding = encoding
2106
handler = logging.StreamHandler(stream=stderr)
2107
handler.setLevel(logging.INFO)
2109
logger = logging.getLogger('')
2110
logger.addHandler(handler)
2113
result = self._run_bzr_core(
2114
args, encoding=encoding, stdin=stdin, stdout=stdout,
2115
stderr=stderr, working_dir=working_dir)
2117
logger.removeHandler(handler)
2119
out = stdout.getvalue()
2120
err = stderr.getvalue()
2122
self.log('output:\n%r', out)
2124
self.log('errors:\n%r', err)
2125
if retcode is not None:
2126
self.assertEqual(retcode, result,
2127
message='Unexpected return code')
1855
2128
self.assertIsInstance(error_regexes, (list, tuple))
1856
2129
for regex in error_regexes:
1857
2130
self.assertContainsRe(err, regex)
1858
2131
return out, err
1860
2133
def run_bzr_error(self, error_regexes, *args, **kwargs):
1861
"""Run bzr, and check that stderr contains the supplied regexes
2134
"""Run brz, and check that stderr contains the supplied regexes
1863
2136
:param error_regexes: Sequence of regular expressions which
1864
2137
must each be found in the error output. The relative ordering
1865
2138
is not enforced.
1866
:param args: command-line arguments for bzr
1867
:param kwargs: Keyword arguments which are interpreted by run_bzr
2139
:param args: command-line arguments for brz
2140
:param kwargs: Keyword arguments which are interpreted by run_brz
1868
2141
This function changes the default value of retcode to be 3,
1869
since in most cases this is run when you expect bzr to fail.
2142
since in most cases this is run when you expect brz to fail.
1871
2144
:return: (out, err) The actual output of running the command (in case
1872
2145
you want to do more inspection)
3617
3985
# This alias allows to detect typos ('bzrlin.') by making all valid test ids
3618
# appear prefixed ('bzrlib.' is "replaced" by 'bzrlib.').
3619
test_prefix_alias_registry.register('bzrlib', 'bzrlib')
3986
# appear prefixed ('breezy.' is "replaced" by 'breezy.').
3987
test_prefix_alias_registry.register('breezy', 'breezy')
3621
3989
# Obvious highest levels prefixes, feel free to add your own via a plugin
3622
test_prefix_alias_registry.register('bd', 'bzrlib.doc')
3623
test_prefix_alias_registry.register('bu', 'bzrlib.utils')
3624
test_prefix_alias_registry.register('bt', 'bzrlib.tests')
3625
test_prefix_alias_registry.register('bb', 'bzrlib.tests.blackbox')
3626
test_prefix_alias_registry.register('bp', 'bzrlib.plugins')
3990
test_prefix_alias_registry.register('bd', 'breezy.doc')
3991
test_prefix_alias_registry.register('bu', 'breezy.utils')
3992
test_prefix_alias_registry.register('bt', 'breezy.tests')
3993
test_prefix_alias_registry.register('bb', 'breezy.tests.blackbox')
3994
test_prefix_alias_registry.register('bp', 'breezy.plugins')
3629
3997
def _test_suite_testmod_names():
3630
3998
"""Return the standard list of test module names to test."""
3633
'bzrlib.tests.blackbox',
3634
'bzrlib.tests.commands',
3635
'bzrlib.tests.per_branch',
3636
'bzrlib.tests.per_bzrdir',
3637
'bzrlib.tests.per_bzrdir_colo',
3638
'bzrlib.tests.per_foreign_vcs',
3639
'bzrlib.tests.per_interrepository',
3640
'bzrlib.tests.per_intertree',
3641
'bzrlib.tests.per_inventory',
3642
'bzrlib.tests.per_interbranch',
3643
'bzrlib.tests.per_lock',
3644
'bzrlib.tests.per_merger',
3645
'bzrlib.tests.per_transport',
3646
'bzrlib.tests.per_tree',
3647
'bzrlib.tests.per_pack_repository',
3648
'bzrlib.tests.per_repository',
3649
'bzrlib.tests.per_repository_chk',
3650
'bzrlib.tests.per_repository_reference',
3651
'bzrlib.tests.per_uifactory',
3652
'bzrlib.tests.per_versionedfile',
3653
'bzrlib.tests.per_workingtree',
3654
'bzrlib.tests.test__annotator',
3655
'bzrlib.tests.test__bencode',
3656
'bzrlib.tests.test__chk_map',
3657
'bzrlib.tests.test__dirstate_helpers',
3658
'bzrlib.tests.test__groupcompress',
3659
'bzrlib.tests.test__known_graph',
3660
'bzrlib.tests.test__rio',
3661
'bzrlib.tests.test__simple_set',
3662
'bzrlib.tests.test__static_tuple',
3663
'bzrlib.tests.test__walkdirs_win32',
3664
'bzrlib.tests.test_ancestry',
3665
'bzrlib.tests.test_annotate',
3666
'bzrlib.tests.test_api',
3667
'bzrlib.tests.test_atomicfile',
3668
'bzrlib.tests.test_bad_files',
3669
'bzrlib.tests.test_bisect_multi',
3670
'bzrlib.tests.test_branch',
3671
'bzrlib.tests.test_branchbuilder',
3672
'bzrlib.tests.test_btree_index',
3673
'bzrlib.tests.test_bugtracker',
3674
'bzrlib.tests.test_bundle',
3675
'bzrlib.tests.test_bzrdir',
3676
'bzrlib.tests.test__chunks_to_lines',
3677
'bzrlib.tests.test_cache_utf8',
3678
'bzrlib.tests.test_chk_map',
3679
'bzrlib.tests.test_chk_serializer',
3680
'bzrlib.tests.test_chunk_writer',
3681
'bzrlib.tests.test_clean_tree',
3682
'bzrlib.tests.test_cleanup',
3683
'bzrlib.tests.test_cmdline',
3684
'bzrlib.tests.test_commands',
3685
'bzrlib.tests.test_commit',
3686
'bzrlib.tests.test_commit_merge',
3687
'bzrlib.tests.test_config',
3688
'bzrlib.tests.test_conflicts',
3689
'bzrlib.tests.test_counted_lock',
3690
'bzrlib.tests.test_crash',
3691
'bzrlib.tests.test_decorators',
3692
'bzrlib.tests.test_delta',
3693
'bzrlib.tests.test_debug',
3694
'bzrlib.tests.test_deprecated_graph',
3695
'bzrlib.tests.test_diff',
3696
'bzrlib.tests.test_directory_service',
3697
'bzrlib.tests.test_dirstate',
3698
'bzrlib.tests.test_email_message',
3699
'bzrlib.tests.test_eol_filters',
3700
'bzrlib.tests.test_errors',
3701
'bzrlib.tests.test_export',
3702
'bzrlib.tests.test_extract',
3703
'bzrlib.tests.test_fetch',
3704
'bzrlib.tests.test_fifo_cache',
3705
'bzrlib.tests.test_filters',
3706
'bzrlib.tests.test_ftp_transport',
3707
'bzrlib.tests.test_foreign',
3708
'bzrlib.tests.test_generate_docs',
3709
'bzrlib.tests.test_generate_ids',
3710
'bzrlib.tests.test_globbing',
3711
'bzrlib.tests.test_gpg',
3712
'bzrlib.tests.test_graph',
3713
'bzrlib.tests.test_groupcompress',
3714
'bzrlib.tests.test_hashcache',
3715
'bzrlib.tests.test_help',
3716
'bzrlib.tests.test_hooks',
3717
'bzrlib.tests.test_http',
3718
'bzrlib.tests.test_http_response',
3719
'bzrlib.tests.test_https_ca_bundle',
3720
'bzrlib.tests.test_identitymap',
3721
'bzrlib.tests.test_ignores',
3722
'bzrlib.tests.test_index',
3723
'bzrlib.tests.test_import_tariff',
3724
'bzrlib.tests.test_info',
3725
'bzrlib.tests.test_inv',
3726
'bzrlib.tests.test_inventory_delta',
3727
'bzrlib.tests.test_knit',
3728
'bzrlib.tests.test_lazy_import',
3729
'bzrlib.tests.test_lazy_regex',
3730
'bzrlib.tests.test_lock',
3731
'bzrlib.tests.test_lockable_files',
3732
'bzrlib.tests.test_lockdir',
3733
'bzrlib.tests.test_log',
3734
'bzrlib.tests.test_lru_cache',
3735
'bzrlib.tests.test_lsprof',
3736
'bzrlib.tests.test_mail_client',
3737
'bzrlib.tests.test_matchers',
3738
'bzrlib.tests.test_memorytree',
3739
'bzrlib.tests.test_merge',
3740
'bzrlib.tests.test_merge3',
3741
'bzrlib.tests.test_merge_core',
3742
'bzrlib.tests.test_merge_directive',
3743
'bzrlib.tests.test_missing',
3744
'bzrlib.tests.test_msgeditor',
3745
'bzrlib.tests.test_multiparent',
3746
'bzrlib.tests.test_mutabletree',
3747
'bzrlib.tests.test_nonascii',
3748
'bzrlib.tests.test_options',
3749
'bzrlib.tests.test_osutils',
3750
'bzrlib.tests.test_osutils_encodings',
3751
'bzrlib.tests.test_pack',
3752
'bzrlib.tests.test_patch',
3753
'bzrlib.tests.test_patches',
3754
'bzrlib.tests.test_permissions',
3755
'bzrlib.tests.test_plugins',
3756
'bzrlib.tests.test_progress',
3757
'bzrlib.tests.test_read_bundle',
3758
'bzrlib.tests.test_reconcile',
3759
'bzrlib.tests.test_reconfigure',
3760
'bzrlib.tests.test_registry',
3761
'bzrlib.tests.test_remote',
3762
'bzrlib.tests.test_rename_map',
3763
'bzrlib.tests.test_repository',
3764
'bzrlib.tests.test_revert',
3765
'bzrlib.tests.test_revision',
3766
'bzrlib.tests.test_revisionspec',
3767
'bzrlib.tests.test_revisiontree',
3768
'bzrlib.tests.test_rio',
3769
'bzrlib.tests.test_rules',
3770
'bzrlib.tests.test_sampler',
3771
'bzrlib.tests.test_script',
3772
'bzrlib.tests.test_selftest',
3773
'bzrlib.tests.test_serializer',
3774
'bzrlib.tests.test_setup',
3775
'bzrlib.tests.test_sftp_transport',
3776
'bzrlib.tests.test_shelf',
3777
'bzrlib.tests.test_shelf_ui',
3778
'bzrlib.tests.test_smart',
3779
'bzrlib.tests.test_smart_add',
3780
'bzrlib.tests.test_smart_request',
3781
'bzrlib.tests.test_smart_transport',
3782
'bzrlib.tests.test_smtp_connection',
3783
'bzrlib.tests.test_source',
3784
'bzrlib.tests.test_ssh_transport',
3785
'bzrlib.tests.test_status',
3786
'bzrlib.tests.test_store',
3787
'bzrlib.tests.test_strace',
3788
'bzrlib.tests.test_subsume',
3789
'bzrlib.tests.test_switch',
3790
'bzrlib.tests.test_symbol_versioning',
3791
'bzrlib.tests.test_tag',
3792
'bzrlib.tests.test_testament',
3793
'bzrlib.tests.test_textfile',
3794
'bzrlib.tests.test_textmerge',
3795
'bzrlib.tests.test_timestamp',
3796
'bzrlib.tests.test_trace',
3797
'bzrlib.tests.test_transactions',
3798
'bzrlib.tests.test_transform',
3799
'bzrlib.tests.test_transport',
3800
'bzrlib.tests.test_transport_log',
3801
'bzrlib.tests.test_tree',
3802
'bzrlib.tests.test_treebuilder',
3803
'bzrlib.tests.test_tsort',
3804
'bzrlib.tests.test_tuned_gzip',
3805
'bzrlib.tests.test_ui',
3806
'bzrlib.tests.test_uncommit',
3807
'bzrlib.tests.test_upgrade',
3808
'bzrlib.tests.test_upgrade_stacked',
3809
'bzrlib.tests.test_urlutils',
3810
'bzrlib.tests.test_version',
3811
'bzrlib.tests.test_version_info',
3812
'bzrlib.tests.test_weave',
3813
'bzrlib.tests.test_whitebox',
3814
'bzrlib.tests.test_win32utils',
3815
'bzrlib.tests.test_workingtree',
3816
'bzrlib.tests.test_workingtree_4',
3817
'bzrlib.tests.test_wsgi',
3818
'bzrlib.tests.test_xml',
4000
'breezy.git.tests.test_blackbox',
4001
'breezy.git.tests.test_builder',
4002
'breezy.git.tests.test_branch',
4003
'breezy.git.tests.test_cache',
4004
'breezy.git.tests.test_dir',
4005
'breezy.git.tests.test_fetch',
4006
'breezy.git.tests.test_git_remote_helper',
4007
'breezy.git.tests.test_mapping',
4008
'breezy.git.tests.test_memorytree',
4009
'breezy.git.tests.test_object_store',
4010
'breezy.git.tests.test_pristine_tar',
4011
'breezy.git.tests.test_push',
4012
'breezy.git.tests.test_remote',
4013
'breezy.git.tests.test_repository',
4014
'breezy.git.tests.test_refs',
4015
'breezy.git.tests.test_revspec',
4016
'breezy.git.tests.test_roundtrip',
4017
'breezy.git.tests.test_server',
4018
'breezy.git.tests.test_transportgit',
4019
'breezy.git.tests.test_unpeel_map',
4020
'breezy.git.tests.test_urls',
4021
'breezy.git.tests.test_workingtree',
4022
'breezy.tests.blackbox',
4023
'breezy.tests.commands',
4024
'breezy.tests.per_branch',
4025
'breezy.tests.per_bzrdir',
4026
'breezy.tests.per_controldir',
4027
'breezy.tests.per_controldir_colo',
4028
'breezy.tests.per_foreign_vcs',
4029
'breezy.tests.per_interrepository',
4030
'breezy.tests.per_intertree',
4031
'breezy.tests.per_inventory',
4032
'breezy.tests.per_interbranch',
4033
'breezy.tests.per_lock',
4034
'breezy.tests.per_merger',
4035
'breezy.tests.per_transport',
4036
'breezy.tests.per_tree',
4037
'breezy.tests.per_pack_repository',
4038
'breezy.tests.per_repository',
4039
'breezy.tests.per_repository_chk',
4040
'breezy.tests.per_repository_reference',
4041
'breezy.tests.per_repository_vf',
4042
'breezy.tests.per_uifactory',
4043
'breezy.tests.per_versionedfile',
4044
'breezy.tests.per_workingtree',
4045
'breezy.tests.test__annotator',
4046
'breezy.tests.test__bencode',
4047
'breezy.tests.test__btree_serializer',
4048
'breezy.tests.test__chk_map',
4049
'breezy.tests.test__dirstate_helpers',
4050
'breezy.tests.test__groupcompress',
4051
'breezy.tests.test__known_graph',
4052
'breezy.tests.test__rio',
4053
'breezy.tests.test__simple_set',
4054
'breezy.tests.test__static_tuple',
4055
'breezy.tests.test__walkdirs_win32',
4056
'breezy.tests.test_ancestry',
4057
'breezy.tests.test_annotate',
4058
'breezy.tests.test_atomicfile',
4059
'breezy.tests.test_bad_files',
4060
'breezy.tests.test_bisect',
4061
'breezy.tests.test_bisect_multi',
4062
'breezy.tests.test_branch',
4063
'breezy.tests.test_branchbuilder',
4064
'breezy.tests.test_btree_index',
4065
'breezy.tests.test_bugtracker',
4066
'breezy.tests.test_bundle',
4067
'breezy.tests.test_bzrdir',
4068
'breezy.tests.test__chunks_to_lines',
4069
'breezy.tests.test_cache_utf8',
4070
'breezy.tests.test_chk_map',
4071
'breezy.tests.test_chk_serializer',
4072
'breezy.tests.test_chunk_writer',
4073
'breezy.tests.test_clean_tree',
4074
'breezy.tests.test_cleanup',
4075
'breezy.tests.test_cmdline',
4076
'breezy.tests.test_commands',
4077
'breezy.tests.test_commit',
4078
'breezy.tests.test_commit_merge',
4079
'breezy.tests.test_config',
4080
'breezy.tests.test_conflicts',
4081
'breezy.tests.test_controldir',
4082
'breezy.tests.test_counted_lock',
4083
'breezy.tests.test_crash',
4084
'breezy.tests.test_decorators',
4085
'breezy.tests.test_delta',
4086
'breezy.tests.test_debug',
4087
'breezy.tests.test_diff',
4088
'breezy.tests.test_directory_service',
4089
'breezy.tests.test_dirstate',
4090
'breezy.tests.test_email_message',
4091
'breezy.tests.test_eol_filters',
4092
'breezy.tests.test_errors',
4093
'breezy.tests.test_estimate_compressed_size',
4094
'breezy.tests.test_export',
4095
'breezy.tests.test_export_pot',
4096
'breezy.tests.test_extract',
4097
'breezy.tests.test_features',
4098
'breezy.tests.test_fetch',
4099
'breezy.tests.test_fetch_ghosts',
4100
'breezy.tests.test_fixtures',
4101
'breezy.tests.test_fifo_cache',
4102
'breezy.tests.test_filters',
4103
'breezy.tests.test_filter_tree',
4104
'breezy.tests.test_foreign',
4105
'breezy.tests.test_generate_docs',
4106
'breezy.tests.test_generate_ids',
4107
'breezy.tests.test_globbing',
4108
'breezy.tests.test_gpg',
4109
'breezy.tests.test_graph',
4110
'breezy.tests.test_groupcompress',
4111
'breezy.tests.test_hashcache',
4112
'breezy.tests.test_help',
4113
'breezy.tests.test_hooks',
4114
'breezy.tests.test_http',
4115
'breezy.tests.test_http_response',
4116
'breezy.tests.test_https_ca_bundle',
4117
'breezy.tests.test_https_urllib',
4118
'breezy.tests.test_i18n',
4119
'breezy.tests.test_identitymap',
4120
'breezy.tests.test_ignores',
4121
'breezy.tests.test_index',
4122
'breezy.tests.test_import_tariff',
4123
'breezy.tests.test_info',
4124
'breezy.tests.test_inv',
4125
'breezy.tests.test_inventory_delta',
4126
'breezy.tests.test_knit',
4127
'breezy.tests.test_lazy_import',
4128
'breezy.tests.test_lazy_regex',
4129
'breezy.tests.test_library_state',
4130
'breezy.tests.test_lock',
4131
'breezy.tests.test_lockable_files',
4132
'breezy.tests.test_lockdir',
4133
'breezy.tests.test_log',
4134
'breezy.tests.test_lru_cache',
4135
'breezy.tests.test_lsprof',
4136
'breezy.tests.test_mail_client',
4137
'breezy.tests.test_matchers',
4138
'breezy.tests.test_memorytree',
4139
'breezy.tests.test_merge',
4140
'breezy.tests.test_merge3',
4141
'breezy.tests.test_merge_core',
4142
'breezy.tests.test_merge_directive',
4143
'breezy.tests.test_mergetools',
4144
'breezy.tests.test_missing',
4145
'breezy.tests.test_msgeditor',
4146
'breezy.tests.test_multiparent',
4147
'breezy.tests.test_mutabletree',
4148
'breezy.tests.test_nonascii',
4149
'breezy.tests.test_options',
4150
'breezy.tests.test_osutils',
4151
'breezy.tests.test_osutils_encodings',
4152
'breezy.tests.test_pack',
4153
'breezy.tests.test_patch',
4154
'breezy.tests.test_patches',
4155
'breezy.tests.test_permissions',
4156
'breezy.tests.test_plugins',
4157
'breezy.tests.test_progress',
4158
'breezy.tests.test_pyutils',
4159
'breezy.tests.test_read_bundle',
4160
'breezy.tests.test_reconcile',
4161
'breezy.tests.test_reconfigure',
4162
'breezy.tests.test_registry',
4163
'breezy.tests.test_remote',
4164
'breezy.tests.test_rename_map',
4165
'breezy.tests.test_repository',
4166
'breezy.tests.test_revert',
4167
'breezy.tests.test_revision',
4168
'breezy.tests.test_revisionspec',
4169
'breezy.tests.test_revisiontree',
4170
'breezy.tests.test_rio',
4171
'breezy.tests.test_rules',
4172
'breezy.tests.test_url_policy_open',
4173
'breezy.tests.test_sampler',
4174
'breezy.tests.test_scenarios',
4175
'breezy.tests.test_script',
4176
'breezy.tests.test_selftest',
4177
'breezy.tests.test_serializer',
4178
'breezy.tests.test_setup',
4179
'breezy.tests.test_sftp_transport',
4180
'breezy.tests.test_shelf',
4181
'breezy.tests.test_shelf_ui',
4182
'breezy.tests.test_smart',
4183
'breezy.tests.test_smart_add',
4184
'breezy.tests.test_smart_request',
4185
'breezy.tests.test_smart_signals',
4186
'breezy.tests.test_smart_transport',
4187
'breezy.tests.test_smtp_connection',
4188
'breezy.tests.test_source',
4189
'breezy.tests.test_ssh_transport',
4190
'breezy.tests.test_status',
4191
'breezy.tests.test_strace',
4192
'breezy.tests.test_subsume',
4193
'breezy.tests.test_switch',
4194
'breezy.tests.test_symbol_versioning',
4195
'breezy.tests.test_tag',
4196
'breezy.tests.test_test_server',
4197
'breezy.tests.test_testament',
4198
'breezy.tests.test_textfile',
4199
'breezy.tests.test_textmerge',
4200
'breezy.tests.test_cethread',
4201
'breezy.tests.test_timestamp',
4202
'breezy.tests.test_trace',
4203
'breezy.tests.test_transactions',
4204
'breezy.tests.test_transform',
4205
'breezy.tests.test_transport',
4206
'breezy.tests.test_transport_log',
4207
'breezy.tests.test_tree',
4208
'breezy.tests.test_treebuilder',
4209
'breezy.tests.test_treeshape',
4210
'breezy.tests.test_tsort',
4211
'breezy.tests.test_tuned_gzip',
4212
'breezy.tests.test_ui',
4213
'breezy.tests.test_uncommit',
4214
'breezy.tests.test_upgrade',
4215
'breezy.tests.test_upgrade_stacked',
4216
'breezy.tests.test_upstream_import',
4217
'breezy.tests.test_urlutils',
4218
'breezy.tests.test_utextwrap',
4219
'breezy.tests.test_version',
4220
'breezy.tests.test_version_info',
4221
'breezy.tests.test_versionedfile',
4222
'breezy.tests.test_vf_search',
4223
'breezy.tests.test_views',
4224
'breezy.tests.test_weave',
4225
'breezy.tests.test_whitebox',
4226
'breezy.tests.test_win32utils',
4227
'breezy.tests.test_workingtree',
4228
'breezy.tests.test_workingtree_4',
4229
'breezy.tests.test_wsgi',
4230
'breezy.tests.test_xml',
4301
class _HTTPSServerFeature(Feature):
4302
"""Some tests want an https Server, check if one is available.
4304
Right now, the only way this is available is under python2.6 which provides
4315
def feature_name(self):
4316
return 'HTTPSServer'
4319
HTTPSServerFeature = _HTTPSServerFeature()
4322
class _UnicodeFilename(Feature):
4323
"""Does the filesystem support Unicode filenames?"""
4328
except UnicodeEncodeError:
4330
except (IOError, OSError):
4331
# The filesystem allows the Unicode filename but the file doesn't
4335
# The filesystem allows the Unicode filename and the file exists,
4339
UnicodeFilename = _UnicodeFilename()
4342
class _UTF8Filesystem(Feature):
4343
"""Is the filesystem UTF-8?"""
4346
if osutils._fs_enc.upper() in ('UTF-8', 'UTF8'):
4350
UTF8Filesystem = _UTF8Filesystem()
4353
class _BreakinFeature(Feature):
4354
"""Does this platform support the breakin feature?"""
4357
from bzrlib import breakin
4358
if breakin.determine_signal() is None:
4360
if sys.platform == 'win32':
4361
# Windows doesn't have os.kill, and we catch the SIGBREAK signal.
4362
# We trigger SIGBREAK via a Console api so we need ctypes to
4363
# access the function
4370
def feature_name(self):
4371
return "SIGQUIT or SIGBREAK w/ctypes on win32"
4374
BreakinFeature = _BreakinFeature()
4377
class _CaseInsCasePresFilenameFeature(Feature):
4378
"""Is the file-system case insensitive, but case-preserving?"""
4381
fileno, name = tempfile.mkstemp(prefix='MixedCase')
4383
# first check truly case-preserving for created files, then check
4384
# case insensitive when opening existing files.
4385
name = osutils.normpath(name)
4386
base, rel = osutils.split(name)
4387
found_rel = osutils.canonical_relpath(base, name)
4388
return (found_rel == rel
4389
and os.path.isfile(name.upper())
4390
and os.path.isfile(name.lower()))
4395
def feature_name(self):
4396
return "case-insensitive case-preserving filesystem"
4398
CaseInsCasePresFilenameFeature = _CaseInsCasePresFilenameFeature()
4401
class _CaseInsensitiveFilesystemFeature(Feature):
4402
"""Check if underlying filesystem is case-insensitive but *not* case
4405
# Note that on Windows, Cygwin, MacOS etc, the file-systems are far
4406
# more likely to be case preserving, so this case is rare.
4409
if CaseInsCasePresFilenameFeature.available():
4412
if TestCaseWithMemoryTransport.TEST_ROOT is None:
4413
root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
4414
TestCaseWithMemoryTransport.TEST_ROOT = root
4416
root = TestCaseWithMemoryTransport.TEST_ROOT
4417
tdir = osutils.mkdtemp(prefix='case-sensitive-probe-', suffix='',
4419
name_a = osutils.pathjoin(tdir, 'a')
4420
name_A = osutils.pathjoin(tdir, 'A')
4422
result = osutils.isdir(name_A)
4423
_rmtree_temp_dir(tdir)
4426
def feature_name(self):
4427
return 'case-insensitive filesystem'
4429
CaseInsensitiveFilesystemFeature = _CaseInsensitiveFilesystemFeature()
4432
class _CaseSensitiveFilesystemFeature(Feature):
4435
if CaseInsCasePresFilenameFeature.available():
4437
elif CaseInsensitiveFilesystemFeature.available():
4442
def feature_name(self):
4443
return 'case-sensitive filesystem'
4445
# new coding style is for feature instances to be lowercase
4446
case_sensitive_filesystem_feature = _CaseSensitiveFilesystemFeature()
4449
# Kept for compatibility, use bzrlib.tests.features.subunit instead
4450
SubUnitFeature = _CompatabilityThunkFeature(
4451
deprecated_in((2,1,0)),
4452
'bzrlib.tests.features', 'SubUnitFeature', 'subunit')
4453
4593
# Only define SubUnitBzrRunner if subunit is available.
4455
4595
from subunit import TestProtocolClient
4456
4596
from subunit.test_results import AutoTimingTestResultDecorator
4457
class SubUnitBzrRunner(TextTestRunner):
4598
class SubUnitBzrProtocolClientv1(TestProtocolClient):
4600
def stopTest(self, test):
4601
super(SubUnitBzrProtocolClientv1, self).stopTest(test)
4602
_clear__type_equality_funcs(test)
4604
def addSuccess(self, test, details=None):
4605
# The subunit client always includes the details in the subunit
4606
# stream, but we don't want to include it in ours.
4607
if details is not None and 'log' in details:
4609
return super(SubUnitBzrProtocolClientv1, self).addSuccess(
4612
class SubUnitBzrRunnerv1(TextTestRunner):
4458
4614
def run(self, test):
4459
4615
result = AutoTimingTestResultDecorator(
4460
TestProtocolClient(self.stream))
4616
SubUnitBzrProtocolClientv1(self.stream))
4461
4617
test.run(result)
4463
4619
except ImportError:
4466
class _PosixPermissionsFeature(Feature):
4470
# create temporary file and check if specified perms are maintained.
4473
write_perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
4474
f = tempfile.mkstemp(prefix='bzr_perms_chk_')
4477
os.chmod(name, write_perms)
4479
read_perms = os.stat(name).st_mode & 0777
4481
return (write_perms == read_perms)
4483
return (os.name == 'posix') and has_perms()
4485
def feature_name(self):
4486
return 'POSIX permissions support'
4488
posix_permissions_feature = _PosixPermissionsFeature()
4624
from subunit.run import SubunitTestRunner
4626
class SubUnitBzrRunnerv2(TextTestRunner, SubunitTestRunner):
4628
def __init__(self, stream=sys.stderr, descriptions=0, verbosity=1,
4629
bench_history=None, strict=False, result_decorators=None):
4630
TextTestRunner.__init__(
4631
self, stream=stream,
4632
descriptions=descriptions, verbosity=verbosity,
4633
bench_history=bench_history, strict=strict,
4634
result_decorators=result_decorators)
4635
SubunitTestRunner.__init__(self, verbosity=verbosity,
4638
run = SubunitTestRunner.run