From: nejucomo Date: Fri, 7 Sep 2007 23:15:41 +0000 (-0700) Subject: Add some passing unit tests for testutil.PollMixin. X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/rgr-080307.php?a=commitdiff_plain;h=96f55be844985e37e52e4bea949982c9790302f9;p=tahoe-lafs%2Ftahoe-lafs.git Add some passing unit tests for testutil.PollMixin. --- diff --git a/src/allmydata/test/test_util.py b/src/allmydata/test/test_util.py index 118dd6a7..9e9ba3d4 100644 --- a/src/allmydata/test/test_util.py +++ b/src/allmydata/test/test_util.py @@ -5,7 +5,7 @@ import os from twisted.trial import unittest from allmydata.util import bencode, idlib, humanreadable, mathutil -from allmydata.util import assertutil, fileutil +from allmydata.util import assertutil, fileutil, testutil class IDLib(unittest.TestCase): @@ -368,3 +368,23 @@ class FileUtil(unittest.TestCase): used = fileutil.du(basedir) self.failUnlessEqual(10+11+12+13, used) +class PollMixinTests(unittest.TestCase): + def setUp(self): + self.pm = testutil.PollMixin() + + def _check(self, d): + def fail_unless_arg_is_true(arg): + self.failUnless(arg is True, repr(arg)) + d.addCallback(fail_unless_arg_is_true) + return d + + def test_PollMixin_True(self): + d = self.pm.poll(check_f=lambda : True, + pollinterval=0.1) + return self._check(d) + + def test_PollMixin_False_then_True(self): + i = iter([False, True]) + d = self.pm.poll(check_f=i.next, + pollinterval=0.1) + return self._check(d)