]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
testutil: factor stall() out into a common location
authorBrian Warner <warner@allmydata.com>
Tue, 22 Apr 2008 23:47:15 +0000 (16:47 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 22 Apr 2008 23:47:15 +0000 (16:47 -0700)
src/allmydata/test/test_client.py
src/allmydata/test/test_dirnode.py
src/allmydata/test/test_system.py
src/allmydata/util/testutil.py

index 6c6c77bd16a6bcd1dffc6c44938431be7a090633..9bb889db3af3833230e5f19c9669cb1adcd8a3e9 100644 (file)
@@ -7,7 +7,7 @@ from twisted.python import log
 
 import allmydata
 from allmydata import client, introducer
-from allmydata.util import base32
+from allmydata.util import base32, testutil
 from foolscap.eventual import flushEventualQueue
 
 class FakeIntroducerClient(introducer.IntroducerClient):
@@ -145,7 +145,7 @@ def flush_but_dont_ignore(res):
     d.addCallback(_done)
     return d
 
-class Run(unittest.TestCase):
+class Run(unittest.TestCase, testutil.StallMixin):
 
     def setUp(self):
         self.sparent = service.MultiService()
@@ -163,11 +163,6 @@ class Run(unittest.TestCase):
         open(os.path.join(basedir, "suicide_prevention_hotline"), "w")
         c = client.Client(basedir)
 
-    def stall(self, res=None, delay=1):
-        d = defer.Deferred()
-        reactor.callLater(delay, d.callback, res)
-        return d
-
     def test_reloadable(self):
         basedir = "test_client.Run.test_reloadable"
         os.mkdir(basedir)
index dafc67af2c651b604d5c51293e2646477a5ec310..8522ea5a4135e6ae6b4b533c3992bc7a9b334bdd 100644 (file)
@@ -64,7 +64,7 @@ class FakeClient:
         return d
 
 
-class Dirnode(unittest.TestCase, testutil.ShouldFailMixin):
+class Dirnode(unittest.TestCase, testutil.ShouldFailMixin, testutil.StallMixin):
     def setUp(self):
         self.client = FakeClient()
 
@@ -162,11 +162,6 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin):
     def failUnlessGreaterOrEqualThan(self, a, b):
         self.failUnless(a >= b, "%r should be >= %r" % (a, b))
 
-    def stall(self, res, delay=1.0):
-        d = defer.Deferred()
-        reactor.callLater(delay, d.callback, res)
-        return d
-
     def test_create(self):
         self.expected_manifest = []
 
index 8d46395c48b509a5a88d7e17ba8c46ab3f3bac5e..8ea19858334796ccbc07605d95f180c78a57814c 100644 (file)
@@ -50,7 +50,8 @@ class CountingDataUploadable(upload.Data):
         return upload.Data.read(self, length)
 
 
-class SystemTest(testutil.SignalMixin, testutil.PollMixin, unittest.TestCase):
+class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
+                 unittest.TestCase):
 
     def setUp(self):
         self.sparent = service.MultiService()
@@ -978,11 +979,6 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, unittest.TestCase):
         log.msg(msg, **kwargs)
         return res
 
-    def stall(self, res, delay=1.0):
-        d = defer.Deferred()
-        reactor.callLater(delay, d.callback, res)
-        return d
-
     def _do_publish_private(self, res):
         self.smalldata = "sssh, very secret stuff"
         ut = upload.Data(self.smalldata, convergence=None)
index 21edb8f66e728cc2270b4b859a19c89bf8cd5e7e..d62d905b57155abea6dc6727fc2bfa035ef2f360 100644 (file)
@@ -57,6 +57,12 @@ class PollMixin:
         if check_f():
             lc.stop()
 
+class StallMixin:
+    def stall(self, res=None, delay=1):
+        d = defer.Deferred()
+        reactor.callLater(delay, d.callback, res)
+        return d
+
 class ShouldFailMixin:
 
     def shouldFail(self, expected_failure, which, substring,