Merge 3.4 (test_exceptions)
This commit is contained in:
commit
39c0721d7b
|
@ -10,7 +10,7 @@ import ctypes
|
||||||
|
|
||||||
from test.support import (TESTFN, captured_output, check_impl_detail,
|
from test.support import (TESTFN, captured_output, check_impl_detail,
|
||||||
check_warnings, cpython_only, gc_collect, run_unittest,
|
check_warnings, cpython_only, gc_collect, run_unittest,
|
||||||
no_tracing, unlink, get_attribute)
|
no_tracing, unlink, import_module)
|
||||||
|
|
||||||
class NaiveException(Exception):
|
class NaiveException(Exception):
|
||||||
def __init__(self, x):
|
def __init__(self, x):
|
||||||
|
@ -246,12 +246,15 @@ class ExceptionTests(unittest.TestCase):
|
||||||
self.assertEqual(w.strerror, 'foo')
|
self.assertEqual(w.strerror, 'foo')
|
||||||
self.assertEqual(w.filename, None)
|
self.assertEqual(w.filename, None)
|
||||||
|
|
||||||
|
@unittest.skipUnless(sys.platform == 'win32',
|
||||||
|
'test specific to Windows')
|
||||||
def test_windows_message(self):
|
def test_windows_message(self):
|
||||||
"""Should fill in unknown error code in Windows error message"""
|
"""Should fill in unknown error code in Windows error message"""
|
||||||
windll = get_attribute(ctypes, "windll")
|
ctypes = import_module('ctypes')
|
||||||
code = int.from_bytes(b"\xE0msc", "big")
|
# this error code has no message, Python formats it as hexadecimal
|
||||||
with self.assertRaisesRegex(OSError, hex(code)):
|
code = 3765269347
|
||||||
windll.kernel32.RaiseException(code, 0, 0, None)
|
with self.assertRaisesRegex(OSError, 'Windows Error 0x%x' % code):
|
||||||
|
ctypes.pythonapi.PyErr_SetFromWindowsErr(code)
|
||||||
|
|
||||||
def testAttributes(self):
|
def testAttributes(self):
|
||||||
# test that exception attributes are happy
|
# test that exception attributes are happy
|
||||||
|
|
Loading…
Reference in New Issue