diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-04-02 12:22:44 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-04-02 12:22:44 (GMT) |
commit | 39c0721d7b1872845e1cbb39bbb00eb23571d7c7 (patch) | |
tree | 8e958d4746199109d32d07100803f184674c839a /Lib | |
parent | acd8e7c1f54a12e515042591690b9379fce5ea0d (diff) | |
parent | d223fa631d6fd2822b4cc8ec11b19f5e6d0f415d (diff) | |
download | cpython-39c0721d7b1872845e1cbb39bbb00eb23571d7c7.zip cpython-39c0721d7b1872845e1cbb39bbb00eb23571d7c7.tar.gz cpython-39c0721d7b1872845e1cbb39bbb00eb23571d7c7.tar.bz2 |
Merge 3.4 (test_exceptions)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_exceptions.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 493cd2f..a7f19cb 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -10,7 +10,7 @@ import ctypes from test.support import (TESTFN, captured_output, check_impl_detail, check_warnings, cpython_only, gc_collect, run_unittest, - no_tracing, unlink, get_attribute) + no_tracing, unlink, import_module) class NaiveException(Exception): def __init__(self, x): @@ -246,12 +246,15 @@ class ExceptionTests(unittest.TestCase): self.assertEqual(w.strerror, 'foo') self.assertEqual(w.filename, None) + @unittest.skipUnless(sys.platform == 'win32', + 'test specific to Windows') def test_windows_message(self): """Should fill in unknown error code in Windows error message""" - windll = get_attribute(ctypes, "windll") - code = int.from_bytes(b"\xE0msc", "big") - with self.assertRaisesRegex(OSError, hex(code)): - windll.kernel32.RaiseException(code, 0, 0, None) + ctypes = import_module('ctypes') + # this error code has no message, Python formats it as hexadecimal + code = 3765269347 + with self.assertRaisesRegex(OSError, 'Windows Error 0x%x' % code): + ctypes.pythonapi.PyErr_SetFromWindowsErr(code) def testAttributes(self): # test that exception attributes are happy |