1741
1507
:returns: The actual attr value.
1509
value = getattr(obj, attr_name)
1743
1510
# 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)
1511
self.addCleanup(setattr, obj, attr_name, value)
1752
1512
if new is not _unitialized_attr:
1753
1513
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
1516
def _cleanEnvironment(self):
1790
for name, value in isolated_environ.items():
1791
self.overrideEnv(name, value)
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)
1793
1578
def _restoreHooks(self):
1794
1579
for klass, (name, hooks) in self._preserved_hooks.items():
1795
1580
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
1582
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')
1583
"""This test has failed for some known reason."""
1584
raise KnownFailure(reason)
1831
1586
def _do_skip(self, result, reason):
1832
self._suppress_log()
1833
1587
addSkip = getattr(result, 'addSkip', None)
1834
1588
if not callable(addSkip):
1835
1589
result.addSuccess(result)
1837
addSkip(self, str(reason))
1591
addSkip(self, reason)
1840
1594
def _do_known_failure(self, result, e):
1841
self._suppress_log()
1842
1595
err = sys.exc_info()
1843
1596
addExpectedFailure = getattr(result, 'addExpectedFailure', None)
1844
1597
if addExpectedFailure is not None:
1959
1779
os.chdir(working_dir)
1963
result = self.apply_redirected(
1964
ui.ui_factory.stdin,
1783
result = self.apply_redirected(ui.ui_factory.stdin,
1965
1784
stdout, stderr,
1966
_mod_commands.run_bzr_catch_user_errors,
1785
bzrlib.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)
1969
1800
ui.ui_factory = old_ui_factory
1970
1801
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')
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,
2130
1855
self.assertIsInstance(error_regexes, (list, tuple))
2131
1856
for regex in error_regexes:
2132
1857
self.assertContainsRe(err, regex)
2133
1858
return out, err
2135
1860
def run_bzr_error(self, error_regexes, *args, **kwargs):
2136
"""Run brz, and check that stderr contains the supplied regexes
1861
"""Run bzr, and check that stderr contains the supplied regexes
2138
1863
:param error_regexes: Sequence of regular expressions which
2139
1864
must each be found in the error output. The relative ordering
2140
1865
is not enforced.
2141
:param args: command-line arguments for brz
2142
:param kwargs: Keyword arguments which are interpreted by run_brz
1866
:param args: command-line arguments for bzr
1867
:param kwargs: Keyword arguments which are interpreted by run_bzr
2143
1868
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.
1869
since in most cases this is run when you expect bzr to fail.
2146
1871
:return: (out, err) The actual output of running the command (in case
2147
1872
you want to do more inspection)
3987
3617
# 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')
3618
# appear prefixed ('bzrlib.' is "replaced" by 'bzrlib.').
3619
test_prefix_alias_registry.register('bzrlib', 'bzrlib')
3991
3621
# 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')
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')
4000
3629
def _test_suite_testmod_names():
4001
3630
"""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',
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',
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')
4599
4453
# Only define SubUnitBzrRunner if subunit is available.
4601
4455
from subunit import TestProtocolClient
4602
4456
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):
4457
class SubUnitBzrRunner(TextTestRunner):
4620
4458
def run(self, test):
4621
4459
result = AutoTimingTestResultDecorator(
4622
SubUnitBzrProtocolClientv1(self.stream))
4460
TestProtocolClient(self.stream))
4623
4461
test.run(result)
4625
4463
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
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()