1507
1726
:returns: The actual attr value.
1509
value = getattr(obj, attr_name)
1510
1728
# The actual value is captured by the call below
1511
self.addCleanup(setattr, obj, attr_name, value)
1729
value = getattr(obj, attr_name, _unitialized_attr)
1730
if value is _unitialized_attr:
1731
# When the test completes, the attribute should not exist, but if
1732
# we aren't setting a value, we don't need to do anything.
1733
if new is not _unitialized_attr:
1734
self.addCleanup(delattr, obj, attr_name)
1736
self.addCleanup(setattr, obj, attr_name, value)
1512
1737
if new is not _unitialized_attr:
1513
1738
setattr(obj, attr_name, new)
1741
def overrideEnv(self, name, new):
1742
"""Set an environment variable, and reset it after the test.
1744
:param name: The environment variable name.
1746
:param new: The value to set the variable to. If None, the
1747
variable is deleted from the environment.
1749
:returns: The actual variable value.
1751
value = osutils.set_or_unset_env(name, new)
1752
self.addCleanup(osutils.set_or_unset_env, name, value)
1755
def recordCalls(self, obj, attr_name):
1756
"""Monkeypatch in a wrapper that will record calls.
1758
The monkeypatch is automatically removed when the test concludes.
1760
:param obj: The namespace holding the reference to be replaced;
1761
typically a module, class, or object.
1762
:param attr_name: A string for the name of the attribute to
1764
:returns: A list that will be extended with one item every time the
1765
function is called, with a tuple of (args, kwargs).
1769
def decorator(*args, **kwargs):
1770
calls.append((args, kwargs))
1771
return orig(*args, **kwargs)
1772
orig = self.overrideAttr(obj, attr_name, decorator)
1516
1775
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)
1776
for name, value in isolated_environ.items():
1777
self.overrideEnv(name, value)
1578
1779
def _restoreHooks(self):
1579
1780
for klass, (name, hooks) in self._preserved_hooks.items():
1580
1781
setattr(klass, name, hooks)
1782
self._preserved_hooks.clear()
1783
breezy.hooks._lazy_hooks = self._preserved_lazy_hooks
1784
self._preserved_lazy_hooks.clear()
1582
1786
def knownFailure(self, reason):
1583
"""This test has failed for some known reason."""
1584
raise KnownFailure(reason)
1787
"""Declare that this test fails for a known reason
1789
Tests that are known to fail should generally be using expectedFailure
1790
with an appropriate reverse assertion if a change could cause the test
1791
to start passing. Conversely if the test has no immediate prospect of
1792
succeeding then using skip is more suitable.
1794
When this method is called while an exception is being handled, that
1795
traceback will be used, otherwise a new exception will be thrown to
1796
provide one but won't be reported.
1798
self._add_reason(reason)
1800
exc_info = sys.exc_info()
1801
if exc_info != (None, None, None):
1802
self._report_traceback(exc_info)
1805
raise self.failureException(reason)
1806
except self.failureException:
1807
exc_info = sys.exc_info()
1808
# GZ 02-08-2011: Maybe cleanup this err.exc_info attribute too?
1809
raise testtools.testcase._ExpectedFailure(exc_info)
1813
def _suppress_log(self):
1814
"""Remove the log info from details."""
1815
self.discardDetail('log')
1586
1817
def _do_skip(self, result, reason):
1818
self._suppress_log()
1587
1819
addSkip = getattr(result, 'addSkip', None)
1588
1820
if not callable(addSkip):
1589
1821
result.addSuccess(result)
1591
addSkip(self, reason)
1823
addSkip(self, str(reason))
1594
1826
def _do_known_failure(self, result, e):
1827
self._suppress_log()
1595
1828
err = sys.exc_info()
1596
1829
addExpectedFailure = getattr(result, 'addExpectedFailure', None)
1597
1830
if addExpectedFailure is not None:
1779
1944
os.chdir(working_dir)
1783
result = self.apply_redirected(ui.ui_factory.stdin,
1948
result = self.apply_redirected(
1949
ui.ui_factory.stdin,
1784
1950
stdout, stderr,
1785
bzrlib.commands.run_bzr_catch_user_errors,
1951
_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
1954
ui.ui_factory = old_ui_factory
1801
1955
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,
1960
def run_bzr_raw(self, args, retcode=0, stdin=None, encoding=None,
1961
working_dir=None, error_regexes=[]):
1962
"""Invoke brz, as if it were run from the command line.
1964
The argument list should not include the brz program name - the
1965
first argument is normally the brz command. Arguments may be
1966
passed in three ways:
1968
1- A list of strings, eg ["commit", "a"]. This is recommended
1969
when the command contains whitespace or metacharacters, or
1970
is built up at run time.
1972
2- A single string, eg "add a". This is the most convenient
1973
for hardcoded commands.
1975
This runs brz through the interface that catches and reports
1976
errors, and with logging set to something approximating the
1977
default, so that error reporting can be checked.
1979
This should be the main method for tests that want to exercise the
1980
overall behavior of the brz application (rather than a unit test
1981
or a functional test of the library.)
1983
This sends the stdout/stderr results into the test's log,
1984
where it may be useful for debugging. See also run_captured.
1986
:keyword stdin: A string to be used as stdin for the command.
1987
:keyword retcode: The status code the command should return;
1989
:keyword working_dir: The directory to run the command in
1990
:keyword error_regexes: A list of expected error messages. If
1991
specified they must be seen in the error output of the command.
1993
if isinstance(args, string_types):
1994
args = shlex.split(args)
1996
if encoding is None:
1997
encoding = osutils.get_user_encoding()
1999
if sys.version_info[0] == 2:
2000
wrapped_stdout = stdout = ui_testing.BytesIOWithEncoding()
2001
wrapped_stderr = stderr = ui_testing.BytesIOWithEncoding()
2002
stdout.encoding = stderr.encoding = encoding
2004
# FIXME: don't call into logging here
2005
handler = trace.EncodedStreamHandler(
2006
stderr, errors="replace")
2010
wrapped_stdout = TextIOWrapper(stdout, encoding)
2011
wrapped_stderr = TextIOWrapper(stderr, encoding)
2012
handler = logging.StreamHandler(wrapped_stderr)
2013
handler.setLevel(logging.INFO)
2015
logger = logging.getLogger('')
2016
logger.addHandler(handler)
2018
result = self._run_bzr_core(
2019
args, encoding=encoding, stdin=stdin, stdout=wrapped_stdout,
2020
stderr=wrapped_stderr, working_dir=working_dir,
2023
logger.removeHandler(handler)
2026
wrapped_stdout.flush()
2027
wrapped_stderr.flush()
2029
out = stdout.getvalue()
2030
err = stderr.getvalue()
2032
self.log('output:\n%r', out)
2034
self.log('errors:\n%r', err)
2035
if retcode is not None:
2036
self.assertEqual(retcode, result,
2037
message='Unexpected return code')
2038
self.assertIsInstance(error_regexes, (list, tuple))
2039
for regex in error_regexes:
2040
self.assertContainsRe(err, regex)
2043
def run_bzr(self, args, retcode=0, stdin=None, encoding=None,
2044
working_dir=None, error_regexes=[]):
2045
"""Invoke brz, as if it were run from the command line.
2047
The argument list should not include the brz program name - the
2048
first argument is normally the brz command. Arguments may be
2049
passed in three ways:
2051
1- A list of strings, eg ["commit", "a"]. This is recommended
2052
when the command contains whitespace or metacharacters, or
2053
is built up at run time.
2055
2- A single string, eg "add a". This is the most convenient
2056
for hardcoded commands.
2058
This runs brz through the interface that catches and reports
2059
errors, and with logging set to something approximating the
2060
default, so that error reporting can be checked.
2062
This should be the main method for tests that want to exercise the
2063
overall behavior of the brz application (rather than a unit test
2064
or a functional test of the library.)
2066
This sends the stdout/stderr results into the test's log,
2067
where it may be useful for debugging. See also run_captured.
2069
:keyword stdin: A string to be used as stdin for the command.
2070
:keyword retcode: The status code the command should return;
2072
:keyword working_dir: The directory to run the command in
2073
:keyword error_regexes: A list of expected error messages. If
2074
specified they must be seen in the error output of the command.
2076
if isinstance(args, string_types):
2077
args = shlex.split(args)
2079
if encoding is None:
2080
encoding = osutils.get_user_encoding()
2082
if sys.version_info[0] == 2:
2083
stdout = ui_testing.BytesIOWithEncoding()
2084
stderr = ui_testing.BytesIOWithEncoding()
2085
stdout.encoding = stderr.encoding = encoding
2086
# FIXME: don't call into logging here
2087
handler = trace.EncodedStreamHandler(
2088
stderr, errors="replace")
2090
stdout = ui_testing.StringIOWithEncoding()
2091
stderr = ui_testing.StringIOWithEncoding()
2092
stdout.encoding = stderr.encoding = encoding
2093
handler = logging.StreamHandler(stream=stderr)
2094
handler.setLevel(logging.INFO)
2096
logger = logging.getLogger('')
2097
logger.addHandler(handler)
2100
result = self._run_bzr_core(args,
2101
encoding=encoding, stdin=stdin, stdout=stdout,
2102
stderr=stderr, working_dir=working_dir,
2105
logger.removeHandler(handler)
2107
out = stdout.getvalue()
2108
err = stderr.getvalue()
2110
self.log('output:\n%r', out)
2112
self.log('errors:\n%r', err)
2113
if retcode is not None:
2114
self.assertEqual(retcode, result,
2115
message='Unexpected return code')
1855
2116
self.assertIsInstance(error_regexes, (list, tuple))
1856
2117
for regex in error_regexes:
1857
2118
self.assertContainsRe(err, regex)
1858
2119
return out, err
1860
2121
def run_bzr_error(self, error_regexes, *args, **kwargs):
1861
"""Run bzr, and check that stderr contains the supplied regexes
2122
"""Run brz, and check that stderr contains the supplied regexes
1863
2124
:param error_regexes: Sequence of regular expressions which
1864
2125
must each be found in the error output. The relative ordering
1865
2126
is not enforced.
1866
:param args: command-line arguments for bzr
1867
:param kwargs: Keyword arguments which are interpreted by run_bzr
2127
:param args: command-line arguments for brz
2128
:param kwargs: Keyword arguments which are interpreted by run_brz
1868
2129
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.
2130
since in most cases this is run when you expect brz to fail.
1871
2132
:return: (out, err) The actual output of running the command (in case
1872
2133
you want to do more inspection)
3617
3954
# 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')
3955
# appear prefixed ('breezy.' is "replaced" by 'breezy.').
3956
test_prefix_alias_registry.register('breezy', 'breezy')
3621
3958
# 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')
3959
test_prefix_alias_registry.register('bd', 'breezy.doc')
3960
test_prefix_alias_registry.register('bu', 'breezy.utils')
3961
test_prefix_alias_registry.register('bt', 'breezy.tests')
3962
test_prefix_alias_registry.register('bb', 'breezy.tests.blackbox')
3963
test_prefix_alias_registry.register('bp', 'breezy.plugins')
3629
3966
def _test_suite_testmod_names():
3630
3967
"""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',
3969
'breezy.git.tests.test_blackbox',
3970
'breezy.git.tests.test_builder',
3971
'breezy.git.tests.test_branch',
3972
'breezy.git.tests.test_cache',
3973
'breezy.git.tests.test_dir',
3974
'breezy.git.tests.test_fetch',
3975
'breezy.git.tests.test_git_remote_helper',
3976
'breezy.git.tests.test_mapping',
3977
'breezy.git.tests.test_memorytree',
3978
'breezy.git.tests.test_object_store',
3979
'breezy.git.tests.test_pristine_tar',
3980
'breezy.git.tests.test_push',
3981
'breezy.git.tests.test_remote',
3982
'breezy.git.tests.test_repository',
3983
'breezy.git.tests.test_refs',
3984
'breezy.git.tests.test_revspec',
3985
'breezy.git.tests.test_roundtrip',
3986
'breezy.git.tests.test_server',
3987
'breezy.git.tests.test_transportgit',
3988
'breezy.git.tests.test_unpeel_map',
3989
'breezy.git.tests.test_urls',
3990
'breezy.git.tests.test_workingtree',
3991
'breezy.tests.blackbox',
3992
'breezy.tests.commands',
3993
'breezy.tests.per_branch',
3994
'breezy.tests.per_bzrdir',
3995
'breezy.tests.per_controldir',
3996
'breezy.tests.per_controldir_colo',
3997
'breezy.tests.per_foreign_vcs',
3998
'breezy.tests.per_interrepository',
3999
'breezy.tests.per_intertree',
4000
'breezy.tests.per_inventory',
4001
'breezy.tests.per_interbranch',
4002
'breezy.tests.per_lock',
4003
'breezy.tests.per_merger',
4004
'breezy.tests.per_transport',
4005
'breezy.tests.per_tree',
4006
'breezy.tests.per_pack_repository',
4007
'breezy.tests.per_repository',
4008
'breezy.tests.per_repository_chk',
4009
'breezy.tests.per_repository_reference',
4010
'breezy.tests.per_repository_vf',
4011
'breezy.tests.per_uifactory',
4012
'breezy.tests.per_versionedfile',
4013
'breezy.tests.per_workingtree',
4014
'breezy.tests.test__annotator',
4015
'breezy.tests.test__bencode',
4016
'breezy.tests.test__btree_serializer',
4017
'breezy.tests.test__chk_map',
4018
'breezy.tests.test__dirstate_helpers',
4019
'breezy.tests.test__groupcompress',
4020
'breezy.tests.test__known_graph',
4021
'breezy.tests.test__rio',
4022
'breezy.tests.test__simple_set',
4023
'breezy.tests.test__static_tuple',
4024
'breezy.tests.test__walkdirs_win32',
4025
'breezy.tests.test_ancestry',
4026
'breezy.tests.test_annotate',
4027
'breezy.tests.test_atomicfile',
4028
'breezy.tests.test_bad_files',
4029
'breezy.tests.test_bisect',
4030
'breezy.tests.test_bisect_multi',
4031
'breezy.tests.test_branch',
4032
'breezy.tests.test_branchbuilder',
4033
'breezy.tests.test_btree_index',
4034
'breezy.tests.test_bugtracker',
4035
'breezy.tests.test_bundle',
4036
'breezy.tests.test_bzrdir',
4037
'breezy.tests.test__chunks_to_lines',
4038
'breezy.tests.test_cache_utf8',
4039
'breezy.tests.test_chk_map',
4040
'breezy.tests.test_chk_serializer',
4041
'breezy.tests.test_chunk_writer',
4042
'breezy.tests.test_clean_tree',
4043
'breezy.tests.test_cleanup',
4044
'breezy.tests.test_cmdline',
4045
'breezy.tests.test_commands',
4046
'breezy.tests.test_commit',
4047
'breezy.tests.test_commit_merge',
4048
'breezy.tests.test_config',
4049
'breezy.tests.test_conflicts',
4050
'breezy.tests.test_controldir',
4051
'breezy.tests.test_counted_lock',
4052
'breezy.tests.test_crash',
4053
'breezy.tests.test_decorators',
4054
'breezy.tests.test_delta',
4055
'breezy.tests.test_debug',
4056
'breezy.tests.test_diff',
4057
'breezy.tests.test_directory_service',
4058
'breezy.tests.test_dirstate',
4059
'breezy.tests.test_email_message',
4060
'breezy.tests.test_eol_filters',
4061
'breezy.tests.test_errors',
4062
'breezy.tests.test_estimate_compressed_size',
4063
'breezy.tests.test_export',
4064
'breezy.tests.test_export_pot',
4065
'breezy.tests.test_extract',
4066
'breezy.tests.test_features',
4067
'breezy.tests.test_fetch',
4068
'breezy.tests.test_fetch_ghosts',
4069
'breezy.tests.test_fixtures',
4070
'breezy.tests.test_fifo_cache',
4071
'breezy.tests.test_filters',
4072
'breezy.tests.test_filter_tree',
4073
'breezy.tests.test_foreign',
4074
'breezy.tests.test_generate_docs',
4075
'breezy.tests.test_generate_ids',
4076
'breezy.tests.test_globbing',
4077
'breezy.tests.test_gpg',
4078
'breezy.tests.test_graph',
4079
'breezy.tests.test_groupcompress',
4080
'breezy.tests.test_hashcache',
4081
'breezy.tests.test_help',
4082
'breezy.tests.test_hooks',
4083
'breezy.tests.test_http',
4084
'breezy.tests.test_http_response',
4085
'breezy.tests.test_https_ca_bundle',
4086
'breezy.tests.test_https_urllib',
4087
'breezy.tests.test_i18n',
4088
'breezy.tests.test_identitymap',
4089
'breezy.tests.test_ignores',
4090
'breezy.tests.test_index',
4091
'breezy.tests.test_import_tariff',
4092
'breezy.tests.test_info',
4093
'breezy.tests.test_inv',
4094
'breezy.tests.test_inventory_delta',
4095
'breezy.tests.test_knit',
4096
'breezy.tests.test_lazy_import',
4097
'breezy.tests.test_lazy_regex',
4098
'breezy.tests.test_library_state',
4099
'breezy.tests.test_lock',
4100
'breezy.tests.test_lockable_files',
4101
'breezy.tests.test_lockdir',
4102
'breezy.tests.test_log',
4103
'breezy.tests.test_lru_cache',
4104
'breezy.tests.test_lsprof',
4105
'breezy.tests.test_mail_client',
4106
'breezy.tests.test_matchers',
4107
'breezy.tests.test_memorytree',
4108
'breezy.tests.test_merge',
4109
'breezy.tests.test_merge3',
4110
'breezy.tests.test_merge_core',
4111
'breezy.tests.test_merge_directive',
4112
'breezy.tests.test_mergetools',
4113
'breezy.tests.test_missing',
4114
'breezy.tests.test_msgeditor',
4115
'breezy.tests.test_multiparent',
4116
'breezy.tests.test_mutabletree',
4117
'breezy.tests.test_nonascii',
4118
'breezy.tests.test_options',
4119
'breezy.tests.test_osutils',
4120
'breezy.tests.test_osutils_encodings',
4121
'breezy.tests.test_pack',
4122
'breezy.tests.test_patch',
4123
'breezy.tests.test_patches',
4124
'breezy.tests.test_permissions',
4125
'breezy.tests.test_plugins',
4126
'breezy.tests.test_progress',
4127
'breezy.tests.test_pyutils',
4128
'breezy.tests.test_read_bundle',
4129
'breezy.tests.test_reconcile',
4130
'breezy.tests.test_reconfigure',
4131
'breezy.tests.test_registry',
4132
'breezy.tests.test_remote',
4133
'breezy.tests.test_rename_map',
4134
'breezy.tests.test_repository',
4135
'breezy.tests.test_revert',
4136
'breezy.tests.test_revision',
4137
'breezy.tests.test_revisionspec',
4138
'breezy.tests.test_revisiontree',
4139
'breezy.tests.test_rio',
4140
'breezy.tests.test_rules',
4141
'breezy.tests.test_url_policy_open',
4142
'breezy.tests.test_sampler',
4143
'breezy.tests.test_scenarios',
4144
'breezy.tests.test_script',
4145
'breezy.tests.test_selftest',
4146
'breezy.tests.test_serializer',
4147
'breezy.tests.test_setup',
4148
'breezy.tests.test_sftp_transport',
4149
'breezy.tests.test_shelf',
4150
'breezy.tests.test_shelf_ui',
4151
'breezy.tests.test_smart',
4152
'breezy.tests.test_smart_add',
4153
'breezy.tests.test_smart_request',
4154
'breezy.tests.test_smart_signals',
4155
'breezy.tests.test_smart_transport',
4156
'breezy.tests.test_smtp_connection',
4157
'breezy.tests.test_source',
4158
'breezy.tests.test_ssh_transport',
4159
'breezy.tests.test_status',
4160
'breezy.tests.test_strace',
4161
'breezy.tests.test_subsume',
4162
'breezy.tests.test_switch',
4163
'breezy.tests.test_symbol_versioning',
4164
'breezy.tests.test_tag',
4165
'breezy.tests.test_test_server',
4166
'breezy.tests.test_testament',
4167
'breezy.tests.test_textfile',
4168
'breezy.tests.test_textmerge',
4169
'breezy.tests.test_cethread',
4170
'breezy.tests.test_timestamp',
4171
'breezy.tests.test_trace',
4172
'breezy.tests.test_transactions',
4173
'breezy.tests.test_transform',
4174
'breezy.tests.test_transport',
4175
'breezy.tests.test_transport_log',
4176
'breezy.tests.test_tree',
4177
'breezy.tests.test_treebuilder',
4178
'breezy.tests.test_treeshape',
4179
'breezy.tests.test_tsort',
4180
'breezy.tests.test_tuned_gzip',
4181
'breezy.tests.test_ui',
4182
'breezy.tests.test_uncommit',
4183
'breezy.tests.test_upgrade',
4184
'breezy.tests.test_upgrade_stacked',
4185
'breezy.tests.test_upstream_import',
4186
'breezy.tests.test_urlutils',
4187
'breezy.tests.test_utextwrap',
4188
'breezy.tests.test_version',
4189
'breezy.tests.test_version_info',
4190
'breezy.tests.test_versionedfile',
4191
'breezy.tests.test_vf_search',
4192
'breezy.tests.test_views',
4193
'breezy.tests.test_weave',
4194
'breezy.tests.test_whitebox',
4195
'breezy.tests.test_win32utils',
4196
'breezy.tests.test_workingtree',
4197
'breezy.tests.test_workingtree_4',
4198
'breezy.tests.test_wsgi',
4199
'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
4560
# Only define SubUnitBzrRunner if subunit is available.
4455
4562
from subunit import TestProtocolClient
4456
4563
from subunit.test_results import AutoTimingTestResultDecorator
4457
class SubUnitBzrRunner(TextTestRunner):
4565
class SubUnitBzrProtocolClientv1(TestProtocolClient):
4567
def stopTest(self, test):
4568
super(SubUnitBzrProtocolClientv1, self).stopTest(test)
4569
_clear__type_equality_funcs(test)
4571
def addSuccess(self, test, details=None):
4572
# The subunit client always includes the details in the subunit
4573
# stream, but we don't want to include it in ours.
4574
if details is not None and 'log' in details:
4576
return super(SubUnitBzrProtocolClientv1, self).addSuccess(
4579
class SubUnitBzrRunnerv1(TextTestRunner):
4458
4581
def run(self, test):
4459
4582
result = AutoTimingTestResultDecorator(
4460
TestProtocolClient(self.stream))
4583
SubUnitBzrProtocolClientv1(self.stream))
4461
4584
test.run(result)
4463
4586
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()
4591
from subunit.run import SubunitTestRunner
4593
class SubUnitBzrRunnerv2(TextTestRunner, SubunitTestRunner):
4595
def __init__(self, stream=sys.stderr, descriptions=0, verbosity=1,
4596
bench_history=None, strict=False, result_decorators=None):
4597
TextTestRunner.__init__(
4598
self, stream=stream,
4599
descriptions=descriptions, verbosity=verbosity,
4600
bench_history=bench_history, strict=strict,
4601
result_decorators=result_decorators)
4602
SubunitTestRunner.__init__(self, verbosity=verbosity,
4605
run = SubunitTestRunner.run