]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
web: fix the ERROR: line to work the same in python2.4 and 2.5
authorBrian Warner <warner@lothar.com>
Wed, 25 Feb 2009 08:46:21 +0000 (01:46 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 25 Feb 2009 08:46:21 +0000 (01:46 -0700)
src/allmydata/test/test_cli.py
src/allmydata/test/test_web.py
src/allmydata/web/directory.py

index 0befb07554cc495ba1110cf7d66fbcd58223fb1d..5dc529a5b970347bad21eea9366d0b5c48e8eda6 100644 (file)
@@ -1348,8 +1348,7 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
         d.addCallback(lambda ign: self.do_cli("manifest", self.rooturi))
         def _manifest_failed((rc, out, err)):
             self.failIfEqual(rc, 0)
-            self.failUnlessIn("ERROR: ", err)
-            self.failUnlessIn("UnrecoverableFileError", err)
+            self.failUnlessIn("ERROR: UnrecoverableFileError", err)
             # the fatal directory should still show up, as the last line
             self.failUnlessIn(" subdir\n", out)
         d.addCallback(_manifest_failed)
@@ -1357,8 +1356,7 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
         d.addCallback(lambda ign: self.do_cli("deep-check", self.rooturi))
         def _deep_check_failed((rc, out, err)):
             self.failIfEqual(rc, 0)
-            self.failUnlessIn("ERROR: ", err)
-            self.failUnlessIn("UnrecoverableFileError", err)
+            self.failUnlessIn("ERROR: UnrecoverableFileError", err)
             # we want to make sure that the error indication is the last
             # thing that gets emitted
             self.failIf("done:" in out, out)
@@ -1374,8 +1372,7 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
         #def _deep_check_repair_failed((rc, out, err)):
         #    self.failIfEqual(rc, 0)
         #    print err
-        #    self.failUnlessIn("ERROR: ", err)
-        #    self.failUnlessIn("UnrecoverableFileError", err)
+        #    self.failUnlessIn("ERROR: UnrecoverableFileError", err)
         #    self.failIf("done:" in out, out)
         #d.addCallback(_deep_check_repair_failed)
 
index 1663436e9f3b6fedc0f54c4ebacba6de2789b6f1..14153530c8e47b1cda5ec8e719646746a7ce2801 100644 (file)
@@ -2883,13 +2883,8 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
             error_line = lines[first_error]
             error_msg = lines[first_error+1:]
             error_msg_s = "\n".join(error_msg) + "\n"
-            # different pythons repr the exception differently, so sometimes
-            # we get "ERROR: UnrecoverableFileError", and sometimes we get
-            # "ERROR: <allmydata.mutable.common.UnrecoverableFileError
-            # instance at 0x...>".
-            self.failUnlessIn("ERROR: ", error_line)
-            self.failUnlessIn("UnrecoverableFileError", error_line)
-            self.failUnlessIn("no recoverable versions", error_line)
+            self.failUnlessIn("ERROR: UnrecoverableFileError(no recoverable versions)",
+                              error_line)
             self.failUnless(len(error_msg) > 2, error_msg_s) # some traceback
             units = [simplejson.loads(line) for line in lines[:first_error]]
             self.failUnlessEqual(len(units), 5) # includes subdir
@@ -2909,9 +2904,8 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
             error_line = lines[first_error]
             error_msg = lines[first_error+1:]
             error_msg_s = "\n".join(error_msg) + "\n"
-            self.failUnlessIn("ERROR: ", error_line)
-            self.failUnlessIn("UnrecoverableFileError", error_line)
-            self.failUnlessIn("no recoverable versions", error_line)
+            self.failUnlessIn("ERROR: UnrecoverableFileError(no recoverable versions)",
+                              error_line)
             self.failUnless(len(error_msg) > 2, error_msg_s) # some traceback
             units = [simplejson.loads(line) for line in lines[:first_error]]
             self.failUnlessEqual(len(units), 5) # includes subdir
index 9b49c32e91c3ca0733f0abad0bd0f610fda8a854..4a9c8ddb2f603d13339f1d27e04d40f4714de11e 100644 (file)
@@ -406,7 +406,8 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
         d.addErrback(_cancelled)
         def _error(f):
             # signal the error as a non-JSON "ERROR:" line, plus exception
-            msg = "ERROR: %s\n" % repr(f.value)
+            msg = "ERROR: %s(%s)\n" % (f.value.__class__.__name__,
+                                       ", ".join([str(a) for a in f.value.args]))
             msg += str(f)
             return msg
         d.addErrback(_error)
@@ -450,7 +451,8 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
         d.addErrback(_cancelled)
         def _error(f):
             # signal the error as a non-JSON "ERROR:" line, plus exception
-            msg = "ERROR: %s\n" % repr(f.value)
+            msg = "ERROR: %s(%s)\n" % (f.value.__class__.__name__,
+                                       ", ".join([str(a) for a in f.value.args]))
             msg += str(f)
             return msg
         d.addErrback(_error)