Ejemplo n.º 1
0
Archivo: api.py Proyecto: japaks/pulsar
 def test_with_statement(self):
     with Context() as c:
         yield NOT_DONE
         yield NOT_DONE
         raise ValueError
     self.assertIsInstance(c.result, Failure)
     mute_failure(self, c.result)
Ejemplo n.º 2
0
 def test_with_statement(self):
     with Context() as c:
         yield NOT_DONE
         yield NOT_DONE
         raise ValueError
     self.assertIsInstance(c.result, Failure)
     mute_failure(self, c.result)
Ejemplo n.º 3
0
 def test_fail_deferred1(self):
     a = Deferred()
     d1 = Deferred().add_callback(lambda r: a.callback(r+2))\
                    .add_errback(a.callback)
     d1.callback('bla')
     self.assertIsInstance(a.result.error, TypeError)
     self.assertIsInstance(d1.result.error, TypeError)
     mute_failure(self, a.result)
Ejemplo n.º 4
0
 def test_fail_deferred1(self):
     a = Deferred()
     d1 = Deferred().add_callback(lambda r: a.callback(r+2))\
                    .add_errback(a.callback)
     d1.callback('bla')
     self.assertIsInstance(a.result.error, TypeError)
     self.assertIsInstance(d1.result.error, TypeError)
     mute_failure(self, a.result)
Ejemplo n.º 5
0
 def test_traceback(self):
     try:
         yield raise_some_error()
     except Exception:
         failure = Failure(sys.exc_info())
     value = repr(failure)
     self.assertTrue("    return 'ciao' + 4\nTypeError: " in value)
     mute_failure(self, failure)
Ejemplo n.º 6
0
 def __call__(self):
     self.c += 1
     if self.c == self.loops:
         try:
             raise ValueError('test periodic')
         except Exception:
             mute_failure(test, sys.exc_info())
             raise
         finally:
             d.callback(self.c)
Ejemplo n.º 7
0
 def __call__(self):
     self.c += 1
     if self.c == self.loops:
         try:
             raise ValueError('test periodic')
         except Exception:
             mute_failure(test, sys.exc_info())
             raise
         finally:
             d.callback(self.c)
Ejemplo n.º 8
0
 def testRemoteExcInfo(self):
     failure = maybe_failure(Exception("testRemoteExcInfo"))
     remote = pickle.loads(pickle.dumps(failure))
     # Now create a failure from the remote.exc_info
     failure2 = maybe_failure(remote.exc_info)
     self.assertEqual(failure2.exc_info, remote.exc_info)
     self.assertFalse(failure.logged)
     self.assertFalse(failure2.logged)
     mute_failure(self, failure)
     mute_failure(self, remote)
Ejemplo n.º 9
0
 def test_nested_traceback(self):
     try:
         yield raise_some_error()
     except Exception:
         failure1 = Failure(sys.exc_info())
     try:
         yield nested_error()
     except Exception:
         failure2 = Failure(sys.exc_info())
     self.assertEqual(len(failure1.exc_info[2]), 4)
     self.assertEqual(len(failure2.exc_info[2]), 5)
     self.assertEqual(failure1.exc_info[2][2:], failure2.exc_info[2][3:])
     mute_failure(self, failure1)
     mute_failure(self, failure2)
Ejemplo n.º 10
0
 def __call__(self):
     try:
         test.assertNotEqual(current_thread(), thread)
         if self.prev_loop:
             test.assertEqual(ioloop.num_loops, self.prev_loop+1)
     except Exception:
         d.callback(sys.exc_info())
     else:
         self.prev_loop = ioloop.num_loops
         self.c += 1
         if self.c == self.loop:
             d.callback(self.c)
             try:
                 raise ValueError('test call every')
             except Exception:
                 mute_failure(test, Failure(sys.exc_info()))
                 raise
Ejemplo n.º 11
0
 def __call__(self):
     try:
         test.assertNotEqual(current_thread(), thread)
         if self.prev_loop:
             test.assertEqual(ioloop.num_loops, self.prev_loop + 1)
     except Exception:
         d.callback(sys.exc_info())
     else:
         self.prev_loop = ioloop.num_loops
         self.c += 1
         if self.c == self.loop:
             d.callback(self.c)
             try:
                 raise ValueError('test call every')
             except Exception:
                 mute_failure(test, Failure(sys.exc_info()))
                 raise
Ejemplo n.º 12
0
def dodgyhook(test, response):
    try:
        raise ValueError('Dodgy header hook')
    except ValueError:
        mute_failure(test, Failure(sys.exc_info()))
        raise
Ejemplo n.º 13
0
 def test_repr(self):
     failure = maybe_failure(Exception("test_repr"))
     val = str(failure)
     self.assertEqual(repr(failure), val)
     self.assertTrue("Exception: test" in val)
     mute_failure(self, failure)