Skip to content

Commit 30f0ccf

Browse files
committed
gh-151089: Fix mocking in test_ctypes/test_find.py:test_find_library_with_gcc()
ctypes.util.find_library() on POSIX will try ldconfig then gcc then ld. test_find_library_with_gcc() mocks away just the use of ldconfig, so if gcc isn't actually present on the machine (because the tests are being ran on an installed system, for example) then it will happily fall back to using ld, which makes a mockery (pun unintended) of the test case name. Also mock _findLib_ld to return None, so the test either uses gcc or fails if it isn't present.
1 parent 11c93d6 commit 30f0ccf

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/test/test_ctypes/test_find.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def test_find_on_libpath(self):
118118
self.assertEqual(find_library(libname), 'lib%s.so' % libname)
119119

120120
def test_find_library_with_gcc(self):
121-
with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
121+
with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
122+
unittest.mock.patch("ctypes.util._findLib_ld", lambda *args: None):
122123
self.assertNotEqual(find_library('c'), None)
123124

124125
def test_find_library_with_ld(self):

0 commit comments

Comments
 (0)