@@ -133,24 +133,20 @@ def configure_locales(func):
133
133
@classmethod
134
134
def setUpClass (cls ):
135
135
cls .libc_filename = find_library ("c" )
136
+ if cls .libc_filename is None :
137
+ raise unittest .SkipTest ('cannot find libc' )
136
138
137
139
@configure_locales
138
140
def test_localized_error_from_dll (self ):
139
141
dll = CDLL (self .libc_filename )
140
- with self .assertRaises (AttributeError ) as cm :
142
+ with self .assertRaises (AttributeError ):
141
143
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 ))
145
144
146
145
@configure_locales
147
146
def test_localized_error_in_dll (self ):
148
147
dll = CDLL (self .libc_filename )
149
- with self .assertRaises (ValueError ) as cm :
148
+ with self .assertRaises (ValueError ):
150
149
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 ))
154
150
155
151
@unittest .skipUnless (hasattr (_ctypes , 'dlopen' ),
156
152
'test requires _ctypes.dlopen()' )
@@ -172,11 +168,8 @@ def test_localized_error_dlopen(self):
172
168
@configure_locales
173
169
def test_localized_error_dlsym (self ):
174
170
dll = _ctypes .dlopen (self .libc_filename )
175
- with self .assertRaises (OSError ) as cm :
171
+ with self .assertRaises (OSError ):
176
172
_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 ))
180
173
181
174
182
175
if __name__ == "__main__" :
0 commit comments