]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable: improve test coverage slightly
authorBrian Warner <warner@allmydata.com>
Mon, 21 Apr 2008 22:10:50 +0000 (15:10 -0700)
committerBrian Warner <warner@allmydata.com>
Mon, 21 Apr 2008 22:10:50 +0000 (15:10 -0700)
src/allmydata/mutable/common.py
src/allmydata/test/test_mutable.py

index 4e745433e9e4ddfe94ddc8bfa9cdec0f5591f1aa..4eeba9a64db2bdc531debfd8ab8c731be315d7b3 100644 (file)
@@ -16,12 +16,16 @@ class NeedMoreDataError(Exception):
         self.needed_bytes = needed_bytes # up through EOF
         self.encprivkey_offset = encprivkey_offset
         self.encprivkey_length = encprivkey_length
-    def __str__(self):
+    def __repr__(self):
         return "<NeedMoreDataError (%d bytes)>" % self.needed_bytes
 
 class UncoordinatedWriteError(Exception):
     def __repr__(self):
-        return "<%s -- You, oh user, tried to change a file or directory at the same time as another process was trying to change it.  To avoid data loss, don't do this.  Please see docs/write_coordination.html for details.>" % (self.__class__.__name__,)
+        return ("<%s -- You, oh user, tried to change a file or directory "
+                "at the same time as another process was trying to change it. "
+                " To avoid data loss, don't do this.  Please see "
+                "docs/write_coordination.html for details.>" %
+                (self.__class__.__name__,))
 
 class UnrecoverableFileError(Exception):
     pass
index 9018dc445e910a46938e7a2bb3aa5cda33c884b2..66cdf16c75443608672f91b95b45d65739989cdb 100644 (file)
@@ -16,7 +16,7 @@ import sha
 from allmydata.mutable.node import MutableFileNode, BackoffAgent
 from allmydata.mutable.common import DictOfSets, ResponseCache, \
      MODE_CHECK, MODE_ANYTHING, MODE_WRITE, MODE_READ, \
-     UnrecoverableFileError, UncoordinatedWriteError
+     NeedMoreDataError, UnrecoverableFileError, UncoordinatedWriteError
 from allmydata.mutable.retrieve import Retrieve
 from allmydata.mutable.publish import Publish
 from allmydata.mutable.servermap import ServerMap, ServermapUpdater
@@ -1316,3 +1316,10 @@ class Utils(unittest.TestCase):
         c.add("v1", 1, 10, xdata[10:20], "time1")
         #self.failUnlessEqual(c.read("v1", 1, 0, 20), (xdata[:20], "time0"))
 
+class Exceptions(unittest.TestCase):
+    def test_repr(self):
+        nmde = NeedMoreDataError(100, 50, 100)
+        self.failUnless("NeedMoreDataError" in repr(nmde), repr(nmde))
+        ucwe = UncoordinatedWriteError()
+        self.failUnless("UncoordinatedWriteError" in repr(ucwe), repr(ucwe))
+