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
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
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))
+