1741
1506
:returns: The actual attr value.
1508
value = getattr(obj, attr_name)
1743
1509
# The actual value is captured by the call below
1744
value = getattr(obj, attr_name, _unitialized_attr)
1745
if value is _unitialized_attr:
1746
# When the test completes, the attribute should not exist, but if
1747
# we aren't setting a value, we don't need to do anything.
1748
if new is not _unitialized_attr:
1749
self.addCleanup(delattr, obj, attr_name)
1751
self.addCleanup(setattr, obj, attr_name, value)
1510
self.addCleanup(setattr, obj, attr_name, value)
1752
1511
if new is not _unitialized_attr:
1753
1512
setattr(obj, attr_name, new)
1756
def overrideEnv(self, name, new):
1757
"""Set an environment variable, and reset it after the test.
1759
:param name: The environment variable name.
1761
:param new: The value to set the variable to. If None, the
1762
variable is deleted from the environment.
1764
:returns: The actual variable value.
1766
value = osutils.set_or_unset_env(name, new)
1767
self.addCleanup(osutils.set_or_unset_env, name, value)
1770
def recordCalls(self, obj, attr_name):
1771
"""Monkeypatch in a wrapper that will record calls.
1773
The monkeypatch is automatically removed when the test concludes.
1775
:param obj: The namespace holding the reference to be replaced;
1776
typically a module, class, or object.
1777
:param attr_name: A string for the name of the attribute to patch.
1778
:returns: A list that will be extended with one item every time the
1779
function is called, with a tuple of (args, kwargs).
1783
def decorator(*args, **kwargs):
1784
calls.append((args, kwargs))
1785
return orig(*args, **kwargs)
1786
orig = self.overrideAttr(obj, attr_name, decorator)
1789
1515
def _cleanEnvironment(self):
1790
for name, value in isolated_environ.items():
1791
self.overrideEnv(name, value)
1517
'BZR_HOME': None, # Don't inherit BZR_HOME to all the tests.
1518
'HOME': os.getcwd(),
1519
# bzr now uses the Win32 API and doesn't rely on APPDATA, but the
1520
# tests do check our impls match APPDATA
1521
'BZR_EDITOR': None, # test_msgeditor manipulates this variable
1525
'BZREMAIL': None, # may still be present in the environment
1526
'EMAIL': 'jrandom@example.com', # set EMAIL as bzr does not guess
1527
'BZR_PROGRESS_BAR': None,
1529
'BZR_PLUGIN_PATH': None,
1530
'BZR_DISABLE_PLUGINS': None,
1531
'BZR_PLUGINS_AT': None,
1532
'BZR_CONCURRENCY': None,
1533
# Make sure that any text ui tests are consistent regardless of
1534
# the environment the test case is run in; you may want tests that
1535
# test other combinations. 'dumb' is a reasonable guess for tests
1536
# going to a pipe or a StringIO.
1540
'BZR_COLUMNS': '80',
1542
'SSH_AUTH_SOCK': None,
1546
'https_proxy': None,
1547
'HTTPS_PROXY': None,
1552
# Nobody cares about ftp_proxy, FTP_PROXY AFAIK. So far at
1553
# least. If you do (care), please update this comment
1557
'BZR_REMOTE_PATH': None,
1558
# Generally speaking, we don't want apport reporting on crashes in
1559
# the test envirnoment unless we're specifically testing apport,
1560
# so that it doesn't leak into the real system environment. We
1561
# use an env var so it propagates to subprocesses.
1562
'APPORT_DISABLE': '1',
1565
self.addCleanup(self._restoreEnvironment)
1566
for name, value in new_env.iteritems():
1567
self._captureVar(name, value)
1569
def _captureVar(self, name, newvalue):
1570
"""Set an environment variable, and reset it when finished."""
1571
self._old_env[name] = osutils.set_or_unset_env(name, newvalue)
1573
def _restoreEnvironment(self):
1574
for name, value in self._old_env.iteritems():
1575
osutils.set_or_unset_env(name, value)
1793
1577
def _restoreHooks(self):
1794
1578
for klass, (name, hooks) in self._preserved_hooks.items():
1795
1579
setattr(klass, name, hooks)
1796
self._preserved_hooks.clear()
1797
breezy.hooks._lazy_hooks = self._preserved_lazy_hooks
1798
self._preserved_lazy_hooks.clear()
1800
1581
def knownFailure(self, reason):
1801
"""Declare that this test fails for a known reason
1803
Tests that are known to fail should generally be using expectedFailure
1804
with an appropriate reverse assertion if a change could cause the test
1805
to start passing. Conversely if the test has no immediate prospect of
1806
succeeding then using skip is more suitable.
1808
When this method is called while an exception is being handled, that
1809
traceback will be used, otherwise a new exception will be thrown to
1810
provide one but won't be reported.
1812
self._add_reason(reason)
1814
exc_info = sys.exc_info()
1815
if exc_info != (None, None, None):
1816
self._report_traceback(exc_info)
1819
raise self.failureException(reason)
1820
except self.failureException:
1821
exc_info = sys.exc_info()
1822
# GZ 02-08-2011: Maybe cleanup this err.exc_info attribute too?
1823
raise testtools.testcase._ExpectedFailure(exc_info)
1827
def _suppress_log(self):
1828
"""Remove the log info from details."""
1829
self.discardDetail('log')
1582
"""This test has failed for some known reason."""
1583
raise KnownFailure(reason)
1831
1585
def _do_skip(self, result, reason):
1832
self._suppress_log()
1833
1586
addSkip = getattr(result, 'addSkip', None)
1834
1587
if not callable(addSkip):
1835
1588
result.addSuccess(result)
1837
addSkip(self, str(reason))
1590
addSkip(self, reason)
1840
1593
def _do_known_failure(self, result, e):
1841
self._suppress_log()
1842
1594
err = sys.exc_info()
1843
1595
addExpectedFailure = getattr(result, 'addExpectedFailure', None)
1844
1596
if addExpectedFailure is not None:
1959
1778
os.chdir(working_dir)
1963
result = self.apply_redirected(
1964
ui.ui_factory.stdin,
1782
result = self.apply_redirected(ui.ui_factory.stdin,
1965
1783
stdout, stderr,
1966
_mod_commands.run_bzr_catch_user_errors,
1784
bzrlib.commands.run_bzr_catch_user_errors,
1786
except KeyboardInterrupt:
1787
# Reraise KeyboardInterrupt with contents of redirected stdout
1788
# and stderr as arguments, for tests which are interested in
1789
# stdout and stderr and are expecting the exception.
1790
out = stdout.getvalue()
1791
err = stderr.getvalue()
1793
self.log('output:\n%r', out)
1795
self.log('errors:\n%r', err)
1796
raise KeyboardInterrupt(out, err)
1798
logger.removeHandler(handler)
1969
1799
ui.ui_factory = old_ui_factory
1970
1800
if cwd is not None:
1975
def run_bzr_raw(self, args, retcode=0, stdin=None, encoding=None,
1976
working_dir=None, error_regexes=[]):
1977
"""Invoke brz, as if it were run from the command line.
1979
The argument list should not include the brz program name - the
1980
first argument is normally the brz command. Arguments may be
1981
passed in three ways:
1983
1- A list of strings, eg ["commit", "a"]. This is recommended
1984
when the command contains whitespace or metacharacters, or
1985
is built up at run time.
1987
2- A single string, eg "add a". This is the most convenient
1988
for hardcoded commands.
1990
This runs brz through the interface that catches and reports
1991
errors, and with logging set to something approximating the
1992
default, so that error reporting can be checked.
1994
This should be the main method for tests that want to exercise the
1995
overall behavior of the brz application (rather than a unit test
1996
or a functional test of the library.)
1998
This sends the stdout/stderr results into the test's log,
1999
where it may be useful for debugging. See also run_captured.
2001
:keyword stdin: A string to be used as stdin for the command.
2002
:keyword retcode: The status code the command should return;
2004
:keyword working_dir: The directory to run the command in
2005
:keyword error_regexes: A list of expected error messages. If
2006
specified they must be seen in the error output of the command.
2008
if isinstance(args, string_types):
2009
args = shlex.split(args)
2011
if encoding is None:
2012
encoding = osutils.get_user_encoding()
2014
if sys.version_info[0] == 2:
2015
wrapped_stdout = stdout = ui_testing.BytesIOWithEncoding()
2016
wrapped_stderr = stderr = ui_testing.BytesIOWithEncoding()
2017
stdout.encoding = stderr.encoding = encoding
2019
# FIXME: don't call into logging here
2020
handler = trace.EncodedStreamHandler(
2021
stderr, errors="replace")
2025
wrapped_stdout = TextIOWrapper(stdout, encoding)
2026
wrapped_stderr = TextIOWrapper(stderr, encoding)
2027
handler = logging.StreamHandler(wrapped_stderr)
2028
handler.setLevel(logging.INFO)
2030
logger = logging.getLogger('')
2031
logger.addHandler(handler)
2033
result = self._run_bzr_core(
2034
args, encoding=encoding, stdin=stdin, stdout=wrapped_stdout,
2035
stderr=wrapped_stderr, working_dir=working_dir,
2038
logger.removeHandler(handler)
2041
wrapped_stdout.flush()
2042
wrapped_stderr.flush()
2044
out = stdout.getvalue()
2045
err = stderr.getvalue()
2047
self.log('output:\n%r', out)
2049
self.log('errors:\n%r', err)
2050
if retcode is not None:
2051
self.assertEqual(retcode, result,
2052
message='Unexpected return code')
2053
self.assertIsInstance(error_regexes, (list, tuple))
2054
for regex in error_regexes:
2055
self.assertContainsRe(err, regex)
2058
def run_bzr(self, args, retcode=0, stdin=None, encoding=None,
2059
working_dir=None, error_regexes=[]):
2060
"""Invoke brz, as if it were run from the command line.
2062
The argument list should not include the brz program name - the
2063
first argument is normally the brz command. Arguments may be
2064
passed in three ways:
2066
1- A list of strings, eg ["commit", "a"]. This is recommended
2067
when the command contains whitespace or metacharacters, or
2068
is built up at run time.
2070
2- A single string, eg "add a". This is the most convenient
2071
for hardcoded commands.
2073
This runs brz through the interface that catches and reports
2074
errors, and with logging set to something approximating the
2075
default, so that error reporting can be checked.
2077
This should be the main method for tests that want to exercise the
2078
overall behavior of the brz application (rather than a unit test
2079
or a functional test of the library.)
2081
This sends the stdout/stderr results into the test's log,
2082
where it may be useful for debugging. See also run_captured.
2084
:keyword stdin: A string to be used as stdin for the command.
2085
:keyword retcode: The status code the command should return;
2087
:keyword working_dir: The directory to run the command in
2088
:keyword error_regexes: A list of expected error messages. If
2089
specified they must be seen in the error output of the command.
2091
if isinstance(args, string_types):
2092
args = shlex.split(args)
2094
if encoding is None:
2095
encoding = osutils.get_user_encoding()
2097
if sys.version_info[0] == 2:
2098
stdout = ui_testing.BytesIOWithEncoding()
2099
stderr = ui_testing.BytesIOWithEncoding()
2100
stdout.encoding = stderr.encoding = encoding
2101
# FIXME: don't call into logging here
2102
handler = trace.EncodedStreamHandler(
2103
stderr, errors="replace")
2105
stdout = ui_testing.StringIOWithEncoding()
2106
stderr = ui_testing.StringIOWithEncoding()
2107
stdout.encoding = stderr.encoding = encoding
2108
handler = logging.StreamHandler(stream=stderr)
2109
handler.setLevel(logging.INFO)
2111
logger = logging.getLogger('')
2112
logger.addHandler(handler)
2115
result = self._run_bzr_core(
2116
args, encoding=encoding, stdin=stdin, stdout=stdout,
2117
stderr=stderr, working_dir=working_dir)
2119
logger.removeHandler(handler)
2121
out = stdout.getvalue()
2122
err = stderr.getvalue()
2124
self.log('output:\n%r', out)
2126
self.log('errors:\n%r', err)
2127
if retcode is not None:
2128
self.assertEqual(retcode, result,
2129
message='Unexpected return code')
1803
out = stdout.getvalue()
1804
err = stderr.getvalue()
1806
self.log('output:\n%r', out)
1808
self.log('errors:\n%r', err)
1809
if retcode is not None:
1810
self.assertEquals(retcode, result,
1811
message='Unexpected return code')
1812
return result, out, err
1814
def run_bzr(self, args, retcode=0, encoding=None, stdin=None,
1815
working_dir=None, error_regexes=[], output_encoding=None):
1816
"""Invoke bzr, as if it were run from the command line.
1818
The argument list should not include the bzr program name - the
1819
first argument is normally the bzr command. Arguments may be
1820
passed in three ways:
1822
1- A list of strings, eg ["commit", "a"]. This is recommended
1823
when the command contains whitespace or metacharacters, or
1824
is built up at run time.
1826
2- A single string, eg "add a". This is the most convenient
1827
for hardcoded commands.
1829
This runs bzr through the interface that catches and reports
1830
errors, and with logging set to something approximating the
1831
default, so that error reporting can be checked.
1833
This should be the main method for tests that want to exercise the
1834
overall behavior of the bzr application (rather than a unit test
1835
or a functional test of the library.)
1837
This sends the stdout/stderr results into the test's log,
1838
where it may be useful for debugging. See also run_captured.
1840
:keyword stdin: A string to be used as stdin for the command.
1841
:keyword retcode: The status code the command should return;
1843
:keyword working_dir: The directory to run the command in
1844
:keyword error_regexes: A list of expected error messages. If
1845
specified they must be seen in the error output of the command.
1847
retcode, out, err = self._run_bzr_autosplit(
1852
working_dir=working_dir,
2130
1854
self.assertIsInstance(error_regexes, (list, tuple))
2131
1855
for regex in error_regexes:
2132
1856
self.assertContainsRe(err, regex)
2133
1857
return out, err
2135
1859
def run_bzr_error(self, error_regexes, *args, **kwargs):
2136
"""Run brz, and check that stderr contains the supplied regexes
1860
"""Run bzr, and check that stderr contains the supplied regexes
2138
1862
:param error_regexes: Sequence of regular expressions which
2139
1863
must each be found in the error output. The relative ordering
2140
1864
is not enforced.
2141
:param args: command-line arguments for brz
2142
:param kwargs: Keyword arguments which are interpreted by run_brz
1865
:param args: command-line arguments for bzr
1866
:param kwargs: Keyword arguments which are interpreted by run_bzr
2143
1867
This function changes the default value of retcode to be 3,
2144
since in most cases this is run when you expect brz to fail.
1868
since in most cases this is run when you expect bzr to fail.
2146
1870
:return: (out, err) The actual output of running the command (in case
2147
1871
you want to do more inspection)
3987
3628
# This alias allows to detect typos ('bzrlin.') by making all valid test ids
3988
# appear prefixed ('breezy.' is "replaced" by 'breezy.').
3989
test_prefix_alias_registry.register('breezy', 'breezy')
3629
# appear prefixed ('bzrlib.' is "replaced" by 'bzrlib.').
3630
test_prefix_alias_registry.register('bzrlib', 'bzrlib')
3991
3632
# Obvious highest levels prefixes, feel free to add your own via a plugin
3992
test_prefix_alias_registry.register('bd', 'breezy.doc')
3993
test_prefix_alias_registry.register('bu', 'breezy.utils')
3994
test_prefix_alias_registry.register('bt', 'breezy.tests')
3995
test_prefix_alias_registry.register('bgt', 'breezy.git.tests')
3996
test_prefix_alias_registry.register('bb', 'breezy.tests.blackbox')
3997
test_prefix_alias_registry.register('bp', 'breezy.plugins')
3633
test_prefix_alias_registry.register('bd', 'bzrlib.doc')
3634
test_prefix_alias_registry.register('bu', 'bzrlib.utils')
3635
test_prefix_alias_registry.register('bt', 'bzrlib.tests')
3636
test_prefix_alias_registry.register('bb', 'bzrlib.tests.blackbox')
3637
test_prefix_alias_registry.register('bp', 'bzrlib.plugins')
4000
3640
def _test_suite_testmod_names():
4001
3641
"""Return the standard list of test module names to test."""
4003
'breezy.git.tests.test_blackbox',
4004
'breezy.git.tests.test_builder',
4005
'breezy.git.tests.test_branch',
4006
'breezy.git.tests.test_cache',
4007
'breezy.git.tests.test_dir',
4008
'breezy.git.tests.test_fetch',
4009
'breezy.git.tests.test_git_remote_helper',
4010
'breezy.git.tests.test_mapping',
4011
'breezy.git.tests.test_memorytree',
4012
'breezy.git.tests.test_object_store',
4013
'breezy.git.tests.test_pristine_tar',
4014
'breezy.git.tests.test_push',
4015
'breezy.git.tests.test_remote',
4016
'breezy.git.tests.test_repository',
4017
'breezy.git.tests.test_refs',
4018
'breezy.git.tests.test_revspec',
4019
'breezy.git.tests.test_roundtrip',
4020
'breezy.git.tests.test_server',
4021
'breezy.git.tests.test_transportgit',
4022
'breezy.git.tests.test_unpeel_map',
4023
'breezy.git.tests.test_urls',
4024
'breezy.git.tests.test_workingtree',
4025
'breezy.tests.blackbox',
4026
'breezy.tests.commands',
4027
'breezy.tests.per_branch',
4028
'breezy.tests.per_bzrdir',
4029
'breezy.tests.per_controldir',
4030
'breezy.tests.per_controldir_colo',
4031
'breezy.tests.per_foreign_vcs',
4032
'breezy.tests.per_interrepository',
4033
'breezy.tests.per_intertree',
4034
'breezy.tests.per_inventory',
4035
'breezy.tests.per_interbranch',
4036
'breezy.tests.per_lock',
4037
'breezy.tests.per_merger',
4038
'breezy.tests.per_transport',
4039
'breezy.tests.per_tree',
4040
'breezy.tests.per_pack_repository',
4041
'breezy.tests.per_repository',
4042
'breezy.tests.per_repository_chk',
4043
'breezy.tests.per_repository_reference',
4044
'breezy.tests.per_repository_vf',
4045
'breezy.tests.per_uifactory',
4046
'breezy.tests.per_versionedfile',
4047
'breezy.tests.per_workingtree',
4048
'breezy.tests.test__annotator',
4049
'breezy.tests.test__bencode',
4050
'breezy.tests.test__btree_serializer',
4051
'breezy.tests.test__chk_map',
4052
'breezy.tests.test__dirstate_helpers',
4053
'breezy.tests.test__groupcompress',
4054
'breezy.tests.test__known_graph',
4055
'breezy.tests.test__rio',
4056
'breezy.tests.test__simple_set',
4057
'breezy.tests.test__static_tuple',
4058
'breezy.tests.test__walkdirs_win32',
4059
'breezy.tests.test_ancestry',
4060
'breezy.tests.test_annotate',
4061
'breezy.tests.test_atomicfile',
4062
'breezy.tests.test_bad_files',
4063
'breezy.tests.test_bisect',
4064
'breezy.tests.test_bisect_multi',
4065
'breezy.tests.test_branch',
4066
'breezy.tests.test_branchbuilder',
4067
'breezy.tests.test_btree_index',
4068
'breezy.tests.test_bugtracker',
4069
'breezy.tests.test_bundle',
4070
'breezy.tests.test_bzrdir',
4071
'breezy.tests.test__chunks_to_lines',
4072
'breezy.tests.test_cache_utf8',
4073
'breezy.tests.test_chk_map',
4074
'breezy.tests.test_chk_serializer',
4075
'breezy.tests.test_chunk_writer',
4076
'breezy.tests.test_clean_tree',
4077
'breezy.tests.test_cleanup',
4078
'breezy.tests.test_cmdline',
4079
'breezy.tests.test_commands',
4080
'breezy.tests.test_commit',
4081
'breezy.tests.test_commit_merge',
4082
'breezy.tests.test_config',
4083
'breezy.tests.test_bedding',
4084
'breezy.tests.test_conflicts',
4085
'breezy.tests.test_controldir',
4086
'breezy.tests.test_counted_lock',
4087
'breezy.tests.test_crash',
4088
'breezy.tests.test_decorators',
4089
'breezy.tests.test_delta',
4090
'breezy.tests.test_debug',
4091
'breezy.tests.test_diff',
4092
'breezy.tests.test_directory_service',
4093
'breezy.tests.test_dirstate',
4094
'breezy.tests.test_email_message',
4095
'breezy.tests.test_eol_filters',
4096
'breezy.tests.test_errors',
4097
'breezy.tests.test_estimate_compressed_size',
4098
'breezy.tests.test_export',
4099
'breezy.tests.test_export_pot',
4100
'breezy.tests.test_extract',
4101
'breezy.tests.test_features',
4102
'breezy.tests.test_fetch',
4103
'breezy.tests.test_fetch_ghosts',
4104
'breezy.tests.test_fixtures',
4105
'breezy.tests.test_fifo_cache',
4106
'breezy.tests.test_filters',
4107
'breezy.tests.test_filter_tree',
4108
'breezy.tests.test_foreign',
4109
'breezy.tests.test_generate_docs',
4110
'breezy.tests.test_generate_ids',
4111
'breezy.tests.test_globbing',
4112
'breezy.tests.test_gpg',
4113
'breezy.tests.test_graph',
4114
'breezy.tests.test_grep',
4115
'breezy.tests.test_groupcompress',
4116
'breezy.tests.test_hashcache',
4117
'breezy.tests.test_help',
4118
'breezy.tests.test_hooks',
4119
'breezy.tests.test_http',
4120
'breezy.tests.test_http_response',
4121
'breezy.tests.test_https_ca_bundle',
4122
'breezy.tests.test_https_urllib',
4123
'breezy.tests.test_i18n',
4124
'breezy.tests.test_identitymap',
4125
'breezy.tests.test_ignores',
4126
'breezy.tests.test_index',
4127
'breezy.tests.test_import_tariff',
4128
'breezy.tests.test_info',
4129
'breezy.tests.test_inv',
4130
'breezy.tests.test_inventory_delta',
4131
'breezy.tests.test_knit',
4132
'breezy.tests.test_lazy_import',
4133
'breezy.tests.test_lazy_regex',
4134
'breezy.tests.test_library_state',
4135
'breezy.tests.test_location',
4136
'breezy.tests.test_lock',
4137
'breezy.tests.test_lockable_files',
4138
'breezy.tests.test_lockdir',
4139
'breezy.tests.test_log',
4140
'breezy.tests.test_lru_cache',
4141
'breezy.tests.test_lsprof',
4142
'breezy.tests.test_mail_client',
4143
'breezy.tests.test_matchers',
4144
'breezy.tests.test_memorytree',
4145
'breezy.tests.test_merge',
4146
'breezy.tests.test_merge3',
4147
'breezy.tests.test_mergeable',
4148
'breezy.tests.test_merge_core',
4149
'breezy.tests.test_merge_directive',
4150
'breezy.tests.test_mergetools',
4151
'breezy.tests.test_missing',
4152
'breezy.tests.test_msgeditor',
4153
'breezy.tests.test_multiparent',
4154
'breezy.tests.test_multiwalker',
4155
'breezy.tests.test_mutabletree',
4156
'breezy.tests.test_nonascii',
4157
'breezy.tests.test_options',
4158
'breezy.tests.test_osutils',
4159
'breezy.tests.test_osutils_encodings',
4160
'breezy.tests.test_pack',
4161
'breezy.tests.test_patch',
4162
'breezy.tests.test_patches',
4163
'breezy.tests.test_permissions',
4164
'breezy.tests.test_plugins',
4165
'breezy.tests.test_progress',
4166
'breezy.tests.test_propose',
4167
'breezy.tests.test_pyutils',
4168
'breezy.tests.test_read_bundle',
4169
'breezy.tests.test_reconcile',
4170
'breezy.tests.test_reconfigure',
4171
'breezy.tests.test_registry',
4172
'breezy.tests.test_remote',
4173
'breezy.tests.test_rename_map',
4174
'breezy.tests.test_repository',
4175
'breezy.tests.test_revert',
4176
'breezy.tests.test_revision',
4177
'breezy.tests.test_revisionspec',
4178
'breezy.tests.test_revisiontree',
4179
'breezy.tests.test_rio',
4180
'breezy.tests.test_rules',
4181
'breezy.tests.test_url_policy_open',
4182
'breezy.tests.test_sampler',
4183
'breezy.tests.test_scenarios',
4184
'breezy.tests.test_script',
4185
'breezy.tests.test_selftest',
4186
'breezy.tests.test_serializer',
4187
'breezy.tests.test_setup',
4188
'breezy.tests.test_sftp_transport',
4189
'breezy.tests.test_shelf',
4190
'breezy.tests.test_shelf_ui',
4191
'breezy.tests.test_smart',
4192
'breezy.tests.test_smart_add',
4193
'breezy.tests.test_smart_request',
4194
'breezy.tests.test_smart_signals',
4195
'breezy.tests.test_smart_transport',
4196
'breezy.tests.test_smtp_connection',
4197
'breezy.tests.test_source',
4198
'breezy.tests.test_ssh_transport',
4199
'breezy.tests.test_status',
4200
'breezy.tests.test_strace',
4201
'breezy.tests.test_subsume',
4202
'breezy.tests.test_switch',
4203
'breezy.tests.test_symbol_versioning',
4204
'breezy.tests.test_tag',
4205
'breezy.tests.test_test_server',
4206
'breezy.tests.test_testament',
4207
'breezy.tests.test_textfile',
4208
'breezy.tests.test_textmerge',
4209
'breezy.tests.test_cethread',
4210
'breezy.tests.test_timestamp',
4211
'breezy.tests.test_trace',
4212
'breezy.tests.test_transactions',
4213
'breezy.tests.test_transform',
4214
'breezy.tests.test_transport',
4215
'breezy.tests.test_transport_log',
4216
'breezy.tests.test_tree',
4217
'breezy.tests.test_treebuilder',
4218
'breezy.tests.test_treeshape',
4219
'breezy.tests.test_tsort',
4220
'breezy.tests.test_tuned_gzip',
4221
'breezy.tests.test_ui',
4222
'breezy.tests.test_uncommit',
4223
'breezy.tests.test_upgrade',
4224
'breezy.tests.test_upgrade_stacked',
4225
'breezy.tests.test_upstream_import',
4226
'breezy.tests.test_urlutils',
4227
'breezy.tests.test_utextwrap',
4228
'breezy.tests.test_version',
4229
'breezy.tests.test_version_info',
4230
'breezy.tests.test_versionedfile',
4231
'breezy.tests.test_vf_search',
4232
'breezy.tests.test_views',
4233
'breezy.tests.test_weave',
4234
'breezy.tests.test_whitebox',
4235
'breezy.tests.test_win32utils',
4236
'breezy.tests.test_workingtree',
4237
'breezy.tests.test_workingtree_4',
4238
'breezy.tests.test_wsgi',
4239
'breezy.tests.test_xml',
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_tsort',
3817
'bzrlib.tests.test_tuned_gzip',
3818
'bzrlib.tests.test_ui',
3819
'bzrlib.tests.test_uncommit',
3820
'bzrlib.tests.test_upgrade',
3821
'bzrlib.tests.test_upgrade_stacked',
3822
'bzrlib.tests.test_urlutils',
3823
'bzrlib.tests.test_version',
3824
'bzrlib.tests.test_version_info',
3825
'bzrlib.tests.test_weave',
3826
'bzrlib.tests.test_whitebox',
3827
'bzrlib.tests.test_win32utils',
3828
'bzrlib.tests.test_workingtree',
3829
'bzrlib.tests.test_workingtree_4',
3830
'bzrlib.tests.test_wsgi',
3831
'bzrlib.tests.test_xml',
4318
class _HTTPSServerFeature(Feature):
4319
"""Some tests want an https Server, check if one is available.
4321
Right now, the only way this is available is under python2.6 which provides
4332
def feature_name(self):
4333
return 'HTTPSServer'
4336
HTTPSServerFeature = _HTTPSServerFeature()
4339
class _UnicodeFilename(Feature):
4340
"""Does the filesystem support Unicode filenames?"""
4345
except UnicodeEncodeError:
4347
except (IOError, OSError):
4348
# The filesystem allows the Unicode filename but the file doesn't
4352
# The filesystem allows the Unicode filename and the file exists,
4356
UnicodeFilename = _UnicodeFilename()
4359
class _ByteStringNamedFilesystem(Feature):
4360
"""Is the filesystem based on bytes?"""
4363
if os.name == "posix":
4367
ByteStringNamedFilesystem = _ByteStringNamedFilesystem()
4370
class _UTF8Filesystem(Feature):
4371
"""Is the filesystem UTF-8?"""
4374
if osutils._fs_enc.upper() in ('UTF-8', 'UTF8'):
4378
UTF8Filesystem = _UTF8Filesystem()
4381
class _BreakinFeature(Feature):
4382
"""Does this platform support the breakin feature?"""
4385
from bzrlib import breakin
4386
if breakin.determine_signal() is None:
4388
if sys.platform == 'win32':
4389
# Windows doesn't have os.kill, and we catch the SIGBREAK signal.
4390
# We trigger SIGBREAK via a Console api so we need ctypes to
4391
# access the function
4398
def feature_name(self):
4399
return "SIGQUIT or SIGBREAK w/ctypes on win32"
4402
BreakinFeature = _BreakinFeature()
4405
class _CaseInsCasePresFilenameFeature(Feature):
4406
"""Is the file-system case insensitive, but case-preserving?"""
4409
fileno, name = tempfile.mkstemp(prefix='MixedCase')
4411
# first check truly case-preserving for created files, then check
4412
# case insensitive when opening existing files.
4413
name = osutils.normpath(name)
4414
base, rel = osutils.split(name)
4415
found_rel = osutils.canonical_relpath(base, name)
4416
return (found_rel == rel
4417
and os.path.isfile(name.upper())
4418
and os.path.isfile(name.lower()))
4423
def feature_name(self):
4424
return "case-insensitive case-preserving filesystem"
4426
CaseInsCasePresFilenameFeature = _CaseInsCasePresFilenameFeature()
4429
class _CaseInsensitiveFilesystemFeature(Feature):
4430
"""Check if underlying filesystem is case-insensitive but *not* case
4433
# Note that on Windows, Cygwin, MacOS etc, the file-systems are far
4434
# more likely to be case preserving, so this case is rare.
4437
if CaseInsCasePresFilenameFeature.available():
4440
if TestCaseWithMemoryTransport.TEST_ROOT is None:
4441
root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
4442
TestCaseWithMemoryTransport.TEST_ROOT = root
4444
root = TestCaseWithMemoryTransport.TEST_ROOT
4445
tdir = osutils.mkdtemp(prefix='case-sensitive-probe-', suffix='',
4447
name_a = osutils.pathjoin(tdir, 'a')
4448
name_A = osutils.pathjoin(tdir, 'A')
4450
result = osutils.isdir(name_A)
4451
_rmtree_temp_dir(tdir)
4454
def feature_name(self):
4455
return 'case-insensitive filesystem'
4457
CaseInsensitiveFilesystemFeature = _CaseInsensitiveFilesystemFeature()
4460
class _CaseSensitiveFilesystemFeature(Feature):
4463
if CaseInsCasePresFilenameFeature.available():
4465
elif CaseInsensitiveFilesystemFeature.available():
4470
def feature_name(self):
4471
return 'case-sensitive filesystem'
4473
# new coding style is for feature instances to be lowercase
4474
case_sensitive_filesystem_feature = _CaseSensitiveFilesystemFeature()
4477
# Kept for compatibility, use bzrlib.tests.features.subunit instead
4478
SubUnitFeature = _CompatabilityThunkFeature(
4479
deprecated_in((2,1,0)),
4480
'bzrlib.tests.features', 'SubUnitFeature', 'subunit')
4599
4481
# Only define SubUnitBzrRunner if subunit is available.
4601
4483
from subunit import TestProtocolClient
4602
4484
from subunit.test_results import AutoTimingTestResultDecorator
4604
class SubUnitBzrProtocolClientv1(TestProtocolClient):
4606
def stopTest(self, test):
4607
super(SubUnitBzrProtocolClientv1, self).stopTest(test)
4608
_clear__type_equality_funcs(test)
4610
def addSuccess(self, test, details=None):
4611
# The subunit client always includes the details in the subunit
4612
# stream, but we don't want to include it in ours.
4613
if details is not None and 'log' in details:
4615
return super(SubUnitBzrProtocolClientv1, self).addSuccess(
4618
class SubUnitBzrRunnerv1(TextTestRunner):
4485
class SubUnitBzrRunner(TextTestRunner):
4620
4486
def run(self, test):
4621
4487
result = AutoTimingTestResultDecorator(
4622
SubUnitBzrProtocolClientv1(self.stream))
4488
TestProtocolClient(self.stream))
4623
4489
test.run(result)
4625
4491
except ImportError:
4630
from subunit.run import SubunitTestRunner
4632
class SubUnitBzrRunnerv2(TextTestRunner, SubunitTestRunner):
4634
def __init__(self, stream=sys.stderr, descriptions=0, verbosity=1,
4635
bench_history=None, strict=False, result_decorators=None):
4636
TextTestRunner.__init__(
4637
self, stream=stream,
4638
descriptions=descriptions, verbosity=verbosity,
4639
bench_history=bench_history, strict=strict,
4640
result_decorators=result_decorators)
4641
SubunitTestRunner.__init__(self, verbosity=verbosity,
4644
run = SubunitTestRunner.run
4494
class _PosixPermissionsFeature(Feature):
4498
# create temporary file and check if specified perms are maintained.
4501
write_perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
4502
f = tempfile.mkstemp(prefix='bzr_perms_chk_')
4505
os.chmod(name, write_perms)
4507
read_perms = os.stat(name).st_mode & 0777
4509
return (write_perms == read_perms)
4511
return (os.name == 'posix') and has_perms()
4513
def feature_name(self):
4514
return 'POSIX permissions support'
4516
posix_permissions_feature = _PosixPermissionsFeature()