mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 16:36:20 +00:00
stop using RuntimeError in unit tests, for #639
This commit is contained in:
parent
d95b01a214
commit
5c3d7d8e73
@ -182,6 +182,9 @@ class FakeClient:
|
||||
def get_cancel_secret(self):
|
||||
return ""
|
||||
|
||||
class GotTooFarError(Exception):
|
||||
pass
|
||||
|
||||
class GiganticUploadable(upload.FileHandle):
|
||||
def __init__(self, size):
|
||||
self._size = size
|
||||
@ -197,7 +200,7 @@ class GiganticUploadable(upload.FileHandle):
|
||||
self._fp += length
|
||||
if self._fp > 1000000:
|
||||
# terminate the test early.
|
||||
raise RuntimeError("we shouldn't be allowed to get this far")
|
||||
raise GotTooFarError("we shouldn't be allowed to get this far")
|
||||
return defer.succeed(["\x00" * length])
|
||||
def close(self):
|
||||
pass
|
||||
|
@ -51,17 +51,17 @@ class HumanReadable(unittest.TestCase):
|
||||
self.failUnlessEqual(hr([1,2]), "[1, 2]")
|
||||
self.failUnlessEqual(hr({1:2}), "{1:2}")
|
||||
try:
|
||||
raise RuntimeError
|
||||
raise ValueError
|
||||
except Exception, e:
|
||||
self.failUnless(
|
||||
hr(e) == "<RuntimeError: ()>" # python-2.4
|
||||
or hr(e) == "RuntimeError()") # python-2.5
|
||||
hr(e) == "<ValueError: ()>" # python-2.4
|
||||
or hr(e) == "ValueError()") # python-2.5
|
||||
try:
|
||||
raise RuntimeError("oops")
|
||||
raise ValueError("oops")
|
||||
except Exception, e:
|
||||
self.failUnless(
|
||||
hr(e) == "<RuntimeError: 'oops'>" # python-2.4
|
||||
or hr(e) == "RuntimeError('oops',)") # python-2.5
|
||||
hr(e) == "<ValueError: 'oops'>" # python-2.4
|
||||
or hr(e) == "ValueError('oops',)") # python-2.5
|
||||
try:
|
||||
raise NoArgumentException
|
||||
except Exception, e:
|
||||
@ -531,12 +531,12 @@ class DeferredUtilTests(unittest.TestCase):
|
||||
d1.addErrback(lambda _ignore: None)
|
||||
d2.addErrback(lambda _ignore: None)
|
||||
d1.callback(1)
|
||||
d2.errback(RuntimeError())
|
||||
d2.errback(ValueError())
|
||||
self.failUnlessEqual(good, [])
|
||||
self.failUnlessEqual(len(bad), 1)
|
||||
f = bad[0]
|
||||
self.failUnless(isinstance(f, failure.Failure))
|
||||
self.failUnless(f.check(RuntimeError))
|
||||
self.failUnless(f.check(ValueError))
|
||||
|
||||
class HashUtilTests(unittest.TestCase):
|
||||
|
||||
@ -694,7 +694,7 @@ class Limiter(unittest.TestCase):
|
||||
return d
|
||||
|
||||
def bad_job(self, i, foo):
|
||||
raise RuntimeError("bad_job %d" % i)
|
||||
raise ValueError("bad_job %d" % i)
|
||||
|
||||
def test_limiter(self):
|
||||
self.calls = []
|
||||
@ -740,7 +740,7 @@ class Limiter(unittest.TestCase):
|
||||
def _good(res):
|
||||
self.fail("should have failed, not got %s" % (res,))
|
||||
def _err(f):
|
||||
f.trap(RuntimeError)
|
||||
f.trap(ValueError)
|
||||
self.failUnless("bad_job 21" in str(f))
|
||||
d2.addCallbacks(_good, _err)
|
||||
return d2
|
||||
|
@ -2973,7 +2973,7 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase):
|
||||
sf = ShareFile(fn)
|
||||
num_leases = len(list(sf.iter_leases()))
|
||||
else:
|
||||
raise RuntimeError("can't get leases on %s" % u)
|
||||
raise ValueError("can't count leases on %s" % u)
|
||||
lease_counts.append( (fn, num_leases) )
|
||||
return lease_counts
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user