Rev 5583: Fix typo, rename BzrDocTestSuite to IsolatedDocTestSuite to dodge the name space controversy and make the intent clearer, add an indirection for setUp/tearDown to prepare more isolation for doctests. in file:///home/vila/src/bzr/bugs/test-isolation/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Dec 24 10:53:49 GMT 2010


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

------------------------------------------------------------
revno: 5583
revision-id: v.ladeuil+lp at free.fr-20101224105349-b22x05h00j0kpfss
parent: v.ladeuil+lp at free.fr-20101223082927-tle4a96tsgh80g2a
fixes bug(s): https://launchpad.net/bugs/321320
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 321320-isolate-doc-tests
timestamp: Fri 2010-12-24 11:53:49 +0100
message:
  Fix typo, rename BzrDocTestSuite to IsolatedDocTestSuite to dodge the name space controversy and make the intent clearer, add an indirection for setUp/tearDown to prepare more isolation for doctests.
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2010-12-23 08:29:27 +0000
+++ b/bzrlib/tests/__init__.py	2010-12-24 10:53:49 +0000
@@ -881,14 +881,22 @@
         return NullProgressView()
 
 
-
-def BzrDocTestSuite(*args, **kwargs):
+def isolated_doctest_setUp(test):
+    override_os_environ(test)
+
+
+def isolated_doctest_tearDown(test):
+    restore_os_environ(test)
+
+
+def IsolatedDocTestSuite(*args, **kwargs):
     """Overrides doctest.DocTestSuite to handle isolation.
 
     The method is really a factory and users are expected to use it as such.
     """
-    kwargs['setUp'] = override_os_environ
-    kwargs['tearDown'] = restore_os_environ
+    
+    kwargs['setUp'] = isolated_doctest_setUp
+    kwargs['tearDown'] = isolated_doctest_tearDown
     return doctest.DocTestSuite(*args, **kwargs)
 
 
@@ -3958,7 +3966,7 @@
         try:
             # note that this really does mean "report only" -- doctest
             # still runs the rest of the examples
-            doc_suite = BzrDocTestSuite(
+            doc_suite = IsolatedDocTestSuite(
                 mod, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)
         except ValueError, e:
             print '**failed to get doctest for: %s\n%s' % (mod, e)

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2010-12-23 08:29:27 +0000
+++ b/bzrlib/tests/test_selftest.py	2010-12-24 10:53:49 +0000
@@ -3461,7 +3461,7 @@
 class TestIsolatedEnv(tests.TestCase):
     """Test isolating tests from os.environ.
 
-    Since we use tests that are already isolated from os.environ abit of care
+    Since we use tests that are already isolated from os.environ a bit of care
     should be taken when designing the tests to avoid bootstrap side-effects.
     The tests start an already clean os.environ which allow doing valid
     assertions about which variables are present or not and design tests around
@@ -3562,7 +3562,7 @@
         # doctest.DocTestSuite fails as it sees '25'
         self.assertDocTestStringFails(doctest.DocTestSuite, test)
         # tests.DocTestSuite sees '42'
-        self.assertDocTestStringSucceds(tests.BzrDocTestSuite, test)
+        self.assertDocTestStringSucceds(tests.IsolatedDocTestSuite, test)
 
     def test_deleted_variable(self):
         self.overrideAttr(tests, 'isolated_environ', {'LINES': None})
@@ -3573,4 +3573,4 @@
         # doctest.DocTestSuite fails as it sees '25'
         self.assertDocTestStringFails(doctest.DocTestSuite, test)
         # tests.DocTestSuite sees None
-        self.assertDocTestStringSucceds(tests.BzrDocTestSuite, test)
+        self.assertDocTestStringSucceds(tests.IsolatedDocTestSuite, test)



More information about the bazaar-commits mailing list