Rev 5576: Cleanup tests imports, they drive me crazy (we had calls for note, trace.log_exception_quietly and bzrlib.trace.warning...) in file:///home/vila/src/bzr/bugs/test-isolation/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Dec 17 16:03:34 GMT 2010


At file:///home/vila/src/bzr/bugs/test-isolation/

------------------------------------------------------------
revno: 5576
revision-id: v.ladeuil+lp at free.fr-20101217160334-eqlngxvvgyog3pkm
parent: v.ladeuil+lp at free.fr-20101217142944-bqdeohokfv1i2ob9
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: even-better
timestamp: Fri 2010-12-17 17:03:34 +0100
message:
  Cleanup tests imports, they drive me crazy (we had calls for note, trace.log_exception_quietly and bzrlib.trace.warning...)
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2010-12-16 17:45:14 +0000
+++ b/bzrlib/tests/__init__.py	2010-12-17 16:03:34 +0000
@@ -64,50 +64,35 @@
     branchbuilder,
     bzrdir,
     chk_map,
+    commands as _mod_commands,
     config,
     debug,
     errors,
     hooks,
     lock as _mod_lock,
+    lockdir,
     memorytree,
     osutils,
+    plugin as _mod_plugin,
     pyutils,
     ui,
     urlutils,
     registry,
+    symbol_versioning,
+    trace,
     transport as _mod_transport,
     workingtree,
     )
-import bzrlib.branch
-import bzrlib.commands
-import bzrlib.timestamp
-import bzrlib.export
-import bzrlib.inventory
-import bzrlib.iterablefile
-import bzrlib.lockdir
 try:
     import bzrlib.lsprof
 except ImportError:
     # lsprof not available
     pass
-import bzrlib.merge3
-import bzrlib.plugin
 from bzrlib.smart import client, request
-import bzrlib.store
-from bzrlib import symbol_versioning
-from bzrlib.symbol_versioning import (
-    DEPRECATED_PARAMETER,
-    deprecated_function,
-    deprecated_in,
-    deprecated_method,
-    deprecated_passed,
-    )
-import bzrlib.trace
 from bzrlib.transport import (
     memory,
     pathfilter,
     )
-from bzrlib.trace import mutter, note
 from bzrlib.tests import (
     test_server,
     TestUtil,
@@ -115,7 +100,6 @@
     )
 from bzrlib.ui import NullProgressView
 from bzrlib.ui.text import TextUIFactory
-import bzrlib.version_info_formats.format_custom
 
 # Mark this python module as being part of the implementation
 # of unittest: this gives us better tracebacks where the last
@@ -1127,7 +1111,7 @@
         except UnicodeError, e:
             # If we can't compare without getting a UnicodeError, then
             # obviously they are different
-            mutter('UnicodeError: %s', e)
+            trace.mutter('UnicodeError: %s', e)
         if message:
             message += '\n'
         raise AssertionError("%snot equal:\na = %s\nb = %s\n"
@@ -1193,7 +1177,6 @@
     def assertLogsError(self, exception_class, func, *args, **kwargs):
         """Assert that func(*args, **kwargs) quietly logs a specific exception.
         """
-        from bzrlib import trace
         captured = []
         orig_log_exception_quietly = trace.log_exception_quietly
         try:
@@ -1493,7 +1476,7 @@
         The file is removed as the test is torn down.
         """
         self._log_file = StringIO()
-        self._log_memento = bzrlib.trace.push_log_file(self._log_file)
+        self._log_memento = trace.push_log_file(self._log_file)
         self.addCleanup(self._finishLogFile)
 
     def _finishLogFile(self):
@@ -1501,10 +1484,10 @@
 
         Close the file and delete it, unless setKeepLogfile was called.
         """
-        if bzrlib.trace._trace_file:
+        if trace._trace_file:
             # flush the log file, to get all content
-            bzrlib.trace._trace_file.flush()
-        bzrlib.trace.pop_log_file(self._log_memento)
+            trace._trace_file.flush()
+        trace.pop_log_file(self._log_memento)
         # Cache the log result and delete the file on disk
         self._get_log(False)
 
@@ -1708,7 +1691,7 @@
             self._benchtime += time.time() - start
 
     def log(self, *args):
-        mutter(*args)
+        trace.mutter(*args)
 
     def _get_log(self, keep_log_file=False):
         """Internal helper to get the log from bzrlib.trace for this test.
@@ -1799,9 +1782,10 @@
 
         try:
             try:
-                result = self.apply_redirected(ui.ui_factory.stdin,
+                result = self.apply_redirected(
+                    ui.ui_factory.stdin,
                     stdout, stderr,
-                    bzrlib.commands.run_bzr_catch_user_errors,
+                    _mod_commands.run_bzr_catch_user_errors,
                     args)
             except KeyboardInterrupt:
                 # Reraise KeyboardInterrupt with contents of redirected stdout
@@ -2057,8 +2041,8 @@
         if retcode is not None and retcode != process.returncode:
             if process_args is None:
                 process_args = "(unknown args)"
-            mutter('Output of bzr %s:\n%s', process_args, out)
-            mutter('Error for bzr %s:\n%s', process_args, err)
+            trace.mutter('Output of bzr %s:\n%s', process_args, out)
+            trace.mutter('Error for bzr %s:\n%s', process_args, err)
             self.fail('Command bzr %s failed with retcode %s != %s'
                       % (process_args, retcode, process.returncode))
         return [out, err]
@@ -2121,7 +2105,7 @@
 
         Tests that expect to provoke LockContention errors should call this.
         """
-        self.overrideAttr(bzrlib.lockdir, '_DEFAULT_TIMEOUT_SECONDS', 0)
+        self.overrideAttr(lockdir, '_DEFAULT_TIMEOUT_SECONDS', 0)
 
     def make_utf8_encoded_stringio(self, encoding_type=None):
         """Return a StringIOWrapper instance, that will encode Unicode
@@ -3608,8 +3592,9 @@
                 key, obj, help=help, info=info, override_existing=False)
         except KeyError:
             actual = self.get(key)
-            note('Test prefix alias %s is already used for %s, ignoring %s'
-                 % (key, actual, obj))
+            trace.note(
+                'Test prefix alias %s is already used for %s, ignoring %s'
+                % (key, actual, obj))
 
     def resolve_alias(self, id_start):
         """Replace the alias by the prefix in the given string.
@@ -3939,7 +3924,7 @@
         suite.addTest(doc_suite)
 
     default_encoding = sys.getdefaultencoding()
-    for name, plugin in bzrlib.plugin.plugins().items():
+    for name, plugin in _mod_plugin.plugins().items():
         if not interesting_module(plugin.module.__name__):
             continue
         plugin_suite = plugin.test_suite()
@@ -3951,7 +3936,7 @@
         if plugin_suite is not None:
             suite.addTest(plugin_suite)
         if default_encoding != sys.getdefaultencoding():
-            bzrlib.trace.warning(
+            trace.warning(
                 'Plugin "%s" tried to reset default encoding to: %s', name,
                 sys.getdefaultencoding())
             reload(sys)
@@ -3972,9 +3957,9 @@
             # Some tests mentioned in the list are not in the test suite. The
             # list may be out of date, report to the tester.
             for id in not_found:
-                bzrlib.trace.warning('"%s" not found in the test suite', id)
+                trace.warning('"%s" not found in the test suite', id)
         for id in duplicates:
-            bzrlib.trace.warning('"%s" is used as an id by several tests', id)
+            trace.warning('"%s" is used as an id by several tests', id)
 
     return suite
 
@@ -4318,13 +4303,6 @@
         return self.module_name
 
 
-# This is kept here for compatibility, it is recommended to use
-# 'bzrlib.tests.feature.paramiko' instead
-ParamikoFeature = _CompatabilityThunkFeature(
-    deprecated_in((2,1,0)),
-    'bzrlib.tests.features', 'ParamikoFeature', 'paramiko')
-
-
 def probe_unicode_in_user_encoding():
     """Try to encode several unicode strings to use in unicode-aware tests.
     Return first successfull match.
@@ -4517,10 +4495,6 @@
 case_sensitive_filesystem_feature = _CaseSensitiveFilesystemFeature()
 
 
-# Kept for compatibility, use bzrlib.tests.features.subunit instead
-SubUnitFeature = _CompatabilityThunkFeature(
-    deprecated_in((2,1,0)),
-    'bzrlib.tests.features', 'SubUnitFeature', 'subunit')
 # Only define SubUnitBzrRunner if subunit is available.
 try:
     from subunit import TestProtocolClient



More information about the bazaar-commits mailing list