Python _testcapi.raise_exception() Examples
The following are 17
code examples of _testcapi.raise_exception().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
_testcapi
, or try the search function
.
Example #1
Source File: test_exceptions.py From ironpython2 with Apache License 2.0 | 6 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException: def __init__(self_): raise RuntimeError, "can't instantiate BadException" def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) else:
Example #2
Source File: test_exceptions.py From BinderFilter with MIT License | 6 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException: def __init__(self_): raise RuntimeError, "can't instantiate BadException" def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) else:
Example #3
Source File: test_exceptions.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException: def __init__(self_): raise RuntimeError, "can't instantiate BadException" def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) else:
Example #4
Source File: test_exceptions.py From oss-ftp with MIT License | 6 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException: def __init__(self_): raise RuntimeError, "can't instantiate BadException" def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) else:
Example #5
Source File: test_exceptions.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException: def __init__(self_): raise RuntimeError, "can't instantiate BadException" def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) else:
Example #6
Source File: test_exceptions.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException: def __init__(self_): raise RuntimeError, "can't instantiate BadException" def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) else:
Example #7
Source File: test_exceptions.py From medicare-demo with Apache License 2.0 | 6 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException: def __init__(self_): raise RuntimeError, "can't instantiate BadException" def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEquals(co.co_name, "test_capi1") self.assert_(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) else:
Example #8
Source File: test_exceptions.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2")
Example #9
Source File: test_exceptions.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2")
Example #10
Source File: test_exceptions.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEquals(co.co_name, "__init__") self.assert_(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) co2 = tb.tb_frame.f_back.f_code self.assertEquals(co2.co_name, "test_capi2")
Example #11
Source File: test_exceptions.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2")
Example #12
Source File: test_exceptions.py From oss-ftp with MIT License | 5 votes |
def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2")
Example #13
Source File: test_exceptions.py From BinderFilter with MIT License | 5 votes |
def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2")
Example #14
Source File: test_exceptions.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2")
Example #15
Source File: test_exceptions.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 4 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException(Exception): def __init__(self_): raise RuntimeError("can't instantiate BadException") class InvalidException: pass def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError as err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions.py')) else: self.fail("Expected exception") def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError as err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions.py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2") else: self.fail("Expected exception") def test_capi3(): import _testcapi self.assertRaises(SystemError, _testcapi.raise_exception, InvalidException, 1) if not sys.platform.startswith('java'): test_capi1() test_capi2() test_capi3()
Example #16
Source File: test_exceptions.py From ironpython3 with Apache License 2.0 | 4 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException(Exception): def __init__(self_): raise RuntimeError("can't instantiate BadException") class InvalidException: pass def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError as err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions.py')) else: self.fail("Expected exception") def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError as err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions.py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2") else: self.fail("Expected exception") def test_capi3(): import _testcapi self.assertRaises(SystemError, _testcapi.raise_exception, InvalidException, 1) if not sys.platform.startswith('java'): test_capi1() test_capi2() test_capi3()
Example #17
Source File: test_exceptions.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def testSettingException(self): # test that setting an exception at the C level works even if the # exception object can't be constructed. class BadException(Exception): def __init__(self_): raise RuntimeError("can't instantiate BadException") class InvalidException: pass def test_capi1(): import _testcapi try: _testcapi.raise_exception(BadException, 1) except TypeError as err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "test_capi1") self.assertTrue(co.co_filename.endswith('test_exceptions.py')) else: self.fail("Expected exception") def test_capi2(): import _testcapi try: _testcapi.raise_exception(BadException, 0) except RuntimeError as err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code self.assertEqual(co.co_name, "__init__") self.assertTrue(co.co_filename.endswith('test_exceptions.py')) co2 = tb.tb_frame.f_back.f_code self.assertEqual(co2.co_name, "test_capi2") else: self.fail("Expected exception") def test_capi3(): import _testcapi self.assertRaises(SystemError, _testcapi.raise_exception, InvalidException, 1) if not sys.platform.startswith('java'): test_capi1() test_capi2() test_capi3()