Rev 3222: Fix bug #137823 by raising UnavailableFeature *after* the fake ftp server in file:///v/home/vila/src/bzr/bugs/137823-selftest-broken-osx/

Vincent Ladeuil v.ladeuil+lp at free.fr
Sun Feb 10 15:51:26 GMT 2008


At file:///v/home/vila/src/bzr/bugs/137823-selftest-broken-osx/

------------------------------------------------------------
revno: 3222
revision-id:v.ladeuil+lp at free.fr-20080210155122-gib8voz2xbausm5c
parent: pqm at pqm.ubuntu.com-20080208064756-bg0zu0y4e789j50r
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 137823-selftest-broken-osx
timestamp: Sun 2008-02-10 16:51:22 +0100
message:
  Fix bug #137823 by raising UnavailableFeature *after* the fake ftp server
  setup is completed.
  
  *  bzrlib/transport/ftp.py:
  (get_test_permutations.UnavailableFTPServer): Raising an exception
  during setup is not correctly handled by the test
  framework. Better raise it on get_url() and get_bogus_url() which
  are always called first when using a server.
  
  *  bzrlib/builtins.py:
  (cmd_selftest.run): 'info()' is about to be deprecated, use note()
  instead.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
  bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-02-07 06:59:48 +0000
+++ b/NEWS	2008-02-10 15:51:22 +0000
@@ -87,7 +87,11 @@
 
     * Clearer error when ``version-info --custom`` is used without
       ``--template`` (Luk???? Lalinsk??)
-      
+
+    * Don't raise UnavailableFeature during test setup when medusa is not
+      available or tearDown is never called leading to nasty side effects.
+      (#137823, Vincent Ladeuil)
+
     * List possible values for BZR_SSH environment variable in env-variables
       help topic. (Alexander Belchenko, #181842)
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-02-01 00:30:33 +0000
+++ b/bzrlib/builtins.py	2008-02-10 15:51:22 +0000
@@ -2657,9 +2657,9 @@
             if benchfile is not None:
                 benchfile.close()
         if result:
-            info('tests passed')
+            note('tests passed')
         else:
-            info('tests failed')
+            note('tests failed')
         return int(not result)
 
 

=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py	2007-12-24 10:31:24 +0000
+++ b/bzrlib/tests/test_transport_implementations.py	2008-02-10 15:51:22 +0000
@@ -96,7 +96,7 @@
                     result.append(scenario)
             except errors.DependencyNotPresent, e:
                 # Continue even if a dependency prevents us 
-                # from running this test
+                # from adding this test
                 pass
         return result
 

=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py	2007-11-25 14:52:24 +0000
+++ b/bzrlib/transport/ftp.py	2008-02-10 15:51:22 +0000
@@ -576,9 +576,21 @@
         return [(FtpTransport, ftp_server.FTPServer)]
     else:
         # Dummy server to have the test suite report the number of tests
-        # needing that feature.
+        # needing that feature. We raise UnavailableFeature from methods before
+        # the test server is being used. Doing so in the setUp method has bad
+        # side-effects (tearDown is never called).
         class UnavailableFTPServer(object):
+
             def setUp(self):
+                pass
+
+            def tearDown(self):
+                pass
+
+            def get_url(self):
+                raise tests.UnavailableFeature(tests.FTPServerFeature)
+
+            def get_bogus_url(self):
                 raise tests.UnavailableFeature(tests.FTPServerFeature)
 
         return [(FtpTransport, UnavailableFTPServer)]



More information about the bazaar-commits mailing list