From: Brian Warner Date: Mon, 21 Apr 2008 22:10:50 +0000 (-0700) Subject: mutable: improve test coverage slightly X-Git-Tag: allmydata-tahoe-1.1.0~203 X-Git-Url: https://git.rkrishnan.org/simplejson/install.html?a=commitdiff_plain;h=a04c2866b1fe690c35bd16d790e630d2303f0914;p=tahoe-lafs%2Ftahoe-lafs.git mutable: improve test coverage slightly --- diff --git a/src/allmydata/mutable/common.py b/src/allmydata/mutable/common.py index 4e745433..4eeba9a6 100644 --- a/src/allmydata/mutable/common.py +++ b/src/allmydata/mutable/common.py @@ -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 "" % 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 diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 9018dc44..66cdf16c 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -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)) +