コード例 #1
0
 def two():
     try:
         exc = TimeoutError()
         with util.timeout(0.02, exc=exc):
             one()
     except Exception, e:
         self.assertFalse(e is exc)
         raise
コード例 #2
0
 def one():
     try:
         exc = TimeoutError()
         with util.timeout(0.01, exc=exc):
             app.sleep(1.0)
     except Exception, e:
         self.assertTrue(e is exc)
         raise
コード例 #3
0
 def one():
     try:
         exc = ZeroDivisionError
         with util.timeout(0.01, exc=exc):
             app.sleep(1.0)
     except Exception, e:
         self.assertTrue(type(e) is exc)
         self.assertEqual(e.args, ())
         raise
コード例 #4
0
 def one():
     try:
         exc = ZeroDivisionError("hello")
         with util.timeout(0.01, exc=exc):
             app.sleep(1.0)
     except Exception, e:
         self.assertTrue(e is exc)
         self.assertEqual(e.args[0], "hello")
         self.assertEqual(type(e), ZeroDivisionError)
         raise
コード例 #5
0
 def testmethod(self):
     try:
         with timeout(t):
             func(self)
     except stacklesslib.errors.TimeoutError:
         self.fail("test case timed out")
コード例 #6
0
 def _notimeout(self, call, timeout=0.01):
     with self.Timer(timeout):
         with util.timeout(timeout):
             return call()
コード例 #7
0
 def three():
     with util.timeout(0.01):
         return two()
コード例 #8
0
 def one():
     with util.timeout(0.06):
         return "foo"
コード例 #9
0
 def two():
     with util.timeout(0.08):
         return one()
コード例 #10
0
 def two():
     with util.timeout(0.08):
         self.assertRaises(TimeoutError, one)
         app.sleep(1.0)
コード例 #11
0
 def three():
     with util.timeout(0.01):
         self.assertRaises(TimeoutError, two)
         app.sleep(1.0)
コード例 #12
0
 def one():
     with util.timeout(0.06):
         app.sleep(1.0)
コード例 #13
0
 def outer():
     with util.timeout(0.01):
         self.assertRaises(TimeoutError, inner)
         raise TimeoutError
         return "foo"
コード例 #14
0
 def inner():
     with util.timeout(0.01):  #long timeout
         app.sleep(2.0)
コード例 #15
0
 def outer():
     with util.timeout(1.0):
         self.assertRaises(TimeoutError, inner)
         return "foo"
コード例 #16
0
 def inner():
     with util.timeout(1.0):  #long timeout
         try:
             app.sleep(2.0)
         except TimeoutError:
             self.assertFalse("this should not have timed out")