[Python-checkins] cpython (3.4): Issue #22977: Fix test_exceptions

victor.stinner python-checkins at python.org
Thu Apr 2 14:23:07 CEST 2015


https://hg.python.org/cpython/rev/dafae2b3c257
changeset: 95379:dafae2b3c257
branch: 3.4
parent: 95373:4255ca2f5314
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Apr 02 14:17:38 2015 +0200
summary:
 Issue #22977: Fix test_exceptions
files:
 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
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -10,7 +10,7 @@
 
 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 @@
 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
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /