Python exceptions 模块,AssertionError() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用exceptions.AssertionError()

项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def test_assertRegex():
    class TestAssertRegex(unittest.TestCase):
        def test(self):
            with self.assertRaises(AssertionError):
                six.assertRegex(self, 'test', r'^a')

            six.assertRegex(self, 'test', r'^t')

    TestAssertRegex('test').test()
项目:splunk_ta_ps4_f1_2016    作者:jonathanvarley    | 项目源码 | 文件源码
def successful(self):
        """
        Return whether the call completed without raising an exception.
        Will raise AssertionError if the result is not ready.
        """

        if not self.ready():
            raise exceptions.AssertionError("Function is not ready")
        res = self._q.get()
        self._q.put(res)

        if isinstance(res, Exception):
            return False
        return True
项目:TA-SyncKVStore    作者:georgestarcher    | 项目源码 | 文件源码
def successful(self):
        """
        Return whether the call completed without raising an exception.
        Will raise AssertionError if the result is not ready.
        """

        if not self.ready():
            raise exceptions.AssertionError("Function is not ready")
        res = self._q.get()
        self._q.put(res)

        if isinstance(res, Exception):
            return False
        return True
项目:cb-defense-splunk-app    作者:carbonblack    | 项目源码 | 文件源码
def successful(self):
        """
        Return whether the call completed without raising an exception.
        Will raise AssertionError if the result is not ready.
        """

        if not self.ready():
            raise exceptions.AssertionError("Function is not ready")
        res = self._q.get()
        self._q.put(res)

        if isinstance(res, Exception):
            return False
        return True
项目:MacHeap    作者:blankwall    | 项目源码 | 文件源码
def __init__(self, object, method, message='', **kwds):
        super(AssertionError,self).__init__(kwds)
        self.object,self.message = object,message
        self.method = method
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def test_assertCountEqual():
    class TestAssertCountEqual(unittest.TestCase):
        def test(self):
            with self.assertRaises(AssertionError):
                six.assertCountEqual(self, (1, 2), [3, 4, 5])

            six.assertCountEqual(self, (1, 2), [2, 1])

    TestAssertCountEqual('test').test()
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def test_assertRaisesRegex():
    class TestAssertRaisesRegex(unittest.TestCase):
        def test(self):
            with six.assertRaisesRegex(self, AssertionError, '^Foo'):
                raise AssertionError('Foo')

            with self.assertRaises(AssertionError):
              with six.assertRaisesRegex(self, AssertionError, r'^Foo'):
                raise AssertionError('Bar')

    TestAssertRaisesRegex('test').test()