@@ -133,24 +133,20 @@ def configure_locales(func):
133133 @classmethod
134134 def setUpClass (cls ):
135135 cls .libc_filename = find_library ("c" )
136+ if cls .libc_filename is None :
137+ raise unittest .SkipTest ('cannot find libc' )
136138
137139 @configure_locales
138140 def test_localized_error_from_dll (self ):
139141 dll = CDLL (self .libc_filename )
140- with self .assertRaises (AttributeError ) as cm :
142+ with self .assertRaises (AttributeError ):
141143 dll .this_name_does_not_exist
142- if sys .platform .startswith ('linux' ):
143- # On macOS, the filename is not reported by dlerror().
144- self .assertIn (self .libc_filename , str (cm .exception ))
145144
146145 @configure_locales
147146 def test_localized_error_in_dll (self ):
148147 dll = CDLL (self .libc_filename )
149- with self .assertRaises (ValueError ) as cm :
148+ with self .assertRaises (ValueError ):
150149 c_int .in_dll (dll , 'this_name_does_not_exist' )
151- if sys .platform .startswith ('linux' ):
152- # On macOS, the filename is not reported by dlerror().
153- self .assertIn (self .libc_filename , str (cm .exception ))
154150
155151 @unittest .skipUnless (hasattr (_ctypes , 'dlopen' ),
156152 'test requires _ctypes.dlopen()' )
@@ -172,11 +168,8 @@ def test_localized_error_dlopen(self):
172168 @configure_locales
173169 def test_localized_error_dlsym (self ):
174170 dll = _ctypes .dlopen (self .libc_filename )
175- with self .assertRaises (OSError ) as cm :
171+ with self .assertRaises (OSError ):
176172 _ctypes .dlsym (dll , 'this_name_does_not_exist' )
177- if sys .platform .startswith ('linux' ):
178- # On macOS, the filename is not reported by dlerror().
179- self .assertIn (self .libc_filename , str (cm .exception ))
180173
181174
182175if __name__ == "__main__" :
0 commit comments