From 96f55be844985e37e52e4bea949982c9790302f9 Mon Sep 17 00:00:00 2001 From: nejucomo Date: Fri, 7 Sep 2007 16:15:41 -0700 Subject: [PATCH] Add some passing unit tests for testutil.PollMixin. --- src/allmydata/test/test_util.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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) -- 2.45.2