예제 #1
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
예제 #2
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
예제 #3
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
예제 #4
0
 def test_sleep(self):
     result = self._timeout(lambda: app.sleep(1.0))
예제 #5
0
 def s():
     with t.timeout():
         app.sleep(0.005)
예제 #6
0
 def three():
     with util.timeout(0.01):
         self.assertRaises(TimeoutError, two)
         app.sleep(1.0)
예제 #7
0
 def two():
     with util.timeout(0.08):
         self.assertRaises(TimeoutError, one)
         app.sleep(1.0)
예제 #8
0
 def one():
     with util.timeout(0.06):
         app.sleep(1.0)
예제 #9
0
 def inner():
     with util.timeout(0.01):  #long timeout
         app.sleep(2.0)
예제 #10
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")