mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
gh-126742: Avoid checking for library filename in test_ctypes (#128034)
Avoid checking for library filename in `dlerror()` error messages of test_ctypes.
This commit is contained in:
parent
0581e3f52b
commit
335e24fb0a
1 changed files with 5 additions and 12 deletions
|
@ -133,24 +133,20 @@ class TestLocalization(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.libc_filename = find_library("c")
|
cls.libc_filename = find_library("c")
|
||||||
|
if cls.libc_filename is None:
|
||||||
|
raise unittest.SkipTest('cannot find libc')
|
||||||
|
|
||||||
@configure_locales
|
@configure_locales
|
||||||
def test_localized_error_from_dll(self):
|
def test_localized_error_from_dll(self):
|
||||||
dll = CDLL(self.libc_filename)
|
dll = CDLL(self.libc_filename)
|
||||||
with self.assertRaises(AttributeError) as cm:
|
with self.assertRaises(AttributeError):
|
||||||
dll.this_name_does_not_exist
|
dll.this_name_does_not_exist
|
||||||
if sys.platform.startswith('linux'):
|
|
||||||
# On macOS, the filename is not reported by dlerror().
|
|
||||||
self.assertIn(self.libc_filename, str(cm.exception))
|
|
||||||
|
|
||||||
@configure_locales
|
@configure_locales
|
||||||
def test_localized_error_in_dll(self):
|
def test_localized_error_in_dll(self):
|
||||||
dll = CDLL(self.libc_filename)
|
dll = CDLL(self.libc_filename)
|
||||||
with self.assertRaises(ValueError) as cm:
|
with self.assertRaises(ValueError):
|
||||||
c_int.in_dll(dll, 'this_name_does_not_exist')
|
c_int.in_dll(dll, 'this_name_does_not_exist')
|
||||||
if sys.platform.startswith('linux'):
|
|
||||||
# On macOS, the filename is not reported by dlerror().
|
|
||||||
self.assertIn(self.libc_filename, str(cm.exception))
|
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(_ctypes, 'dlopen'),
|
@unittest.skipUnless(hasattr(_ctypes, 'dlopen'),
|
||||||
'test requires _ctypes.dlopen()')
|
'test requires _ctypes.dlopen()')
|
||||||
|
@ -172,11 +168,8 @@ class TestLocalization(unittest.TestCase):
|
||||||
@configure_locales
|
@configure_locales
|
||||||
def test_localized_error_dlsym(self):
|
def test_localized_error_dlsym(self):
|
||||||
dll = _ctypes.dlopen(self.libc_filename)
|
dll = _ctypes.dlopen(self.libc_filename)
|
||||||
with self.assertRaises(OSError) as cm:
|
with self.assertRaises(OSError):
|
||||||
_ctypes.dlsym(dll, 'this_name_does_not_exist')
|
_ctypes.dlsym(dll, 'this_name_does_not_exist')
|
||||||
if sys.platform.startswith('linux'):
|
|
||||||
# On macOS, the filename is not reported by dlerror().
|
|
||||||
self.assertIn(self.libc_filename, str(cm.exception))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue