コード例 #1
0
ファイル: test_events.py プロジェクト: kevinfrommelt/biloba
    def test_exc_tuple(self):
        """
        Supplying 3 args means that a return value from ``sys.exc_info()`` is
        being supplied.
        """
        with self.assertRaises(TypeError) as ctx:
            events.get_exc_info('foo', 'bar', 'baz')

        self.assertTrue(unicode(ctx.exception).startswith(
            u"exc_info tuple must be a valid exception instance"
        ))
コード例 #2
0
ファイル: test_events.py プロジェクト: kevinfrommelt/biloba
    def test_missing_args(self):
        """
        Supplying no args must raise a ``TypeError``.
        """
        with self.assertRaises(TypeError) as ctx:
            events.get_exc_info()

        self.assertEqual(
            unicode(ctx.exception),
            u'Expected at least one argument',
        )
コード例 #3
0
ファイル: test_events.py プロジェクト: kevinfrommelt/biloba
    def test_not_an_exception(self):
        """
        Supplying one arg that is not an exception instance must raise a
        ``TypeError``.
        """
        with self.assertRaises(TypeError) as ctx:
            events.get_exc_info('foobar')

        self.assertEqual(
            unicode(ctx.exception),
            u"An exception instance must be supplied as the first argument "
            "(received:'foobar')",
        )
コード例 #4
0
ファイル: test_events.py プロジェクト: kevinfrommelt/biloba
    def test_return_sys_exc_info(self):
        """
        Supplying an exc_info tuple must return a tuple in a ``sys.exc_info()``
        style format.
        """
        exc_info = (RuntimeError, RuntimeError(), None)

        self.assertEqual(
            events.get_exc_info(*exc_info),
            exc_info
        )
コード例 #5
0
ファイル: test_events.py プロジェクト: kevinfrommelt/biloba
    def test_exception(self):
        """
        Supplying an exception instance must return a tuple in a
        ``sys.exc_info()`` style format.
        """
        class TestException(Exception):
            pass

        exc = TestException()
        ret = events.get_exc_info(exc)

        self.assertTupleEqual(ret, (TestException, exc, None))
コード例 #6
0
ファイル: test_events.py プロジェクト: kevinfrommelt/biloba
    def test_exception_class(self):
        """
        Supplying an exception CLASS must return a tuple in a
        ``sys.exc_info()`` style format.
        """
        class TestException(Exception):
            pass

        ret = events.get_exc_info(TestException)

        self.assertEquals(len(ret), 3)
        exc_type, exc_value, exc_tb = ret

        self.assertIs(exc_type, TestException)
        self.assertIsInstance(exc_value, TestException)
        self.assertIsNone(exc_tb)
コード例 #7
0
ファイル: test_events.py プロジェクト: kevinfrommelt/biloba
 def test_4_args(self):
     """
     Supplying 4 args must raise a ``TypeError``.
     """
     with self.assertRaises(TypeError):
         events.get_exc_info('foo', 'bar', 'baz', 'gak')