GeezerVison is showing github.com — [3.11] gh-157983: Skip test for ctypes.util.find_library when ld is m… · python/cpython@b591c95
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Lib/ctypes/test/test_find.py +21-1Lines changed: 21 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import unittest |
2 | 2 | import unittest.mock |
3 | 3 | import os.path |
| 4 | +import subprocess |
4 | 5 | import sys |
5 | 6 | import test.support |
6 | 7 | from test.support import os_helper |
@@ -75,8 +76,27 @@ def test_shell_injection(self): |
75 | 76 | @unittest.skipUnless(sys.platform.startswith('linux'), |
76 | 77 | 'Test only valid for Linux') |
77 | 78 | class FindLibraryLinux(unittest.TestCase): |
| 79 | + @classmethod |
| 80 | + def setUpClass(cls): |
| 81 | + try: |
| 82 | + p = subprocess.run(['ld', '--version'], |
| 83 | + stdout=subprocess.PIPE, |
| 84 | + stderr=subprocess.DEVNULL, |
| 85 | + text=True) |
| 86 | + except OSError: |
| 87 | + pass |
| 88 | + else: |
| 89 | + if p.stdout.startswith('mold '): |
| 90 | + # The mold linker is known to be incompatible with |
| 91 | + # ctypes.util.find_library. The function is |
| 92 | + # documented as "Try to find a library..." |
| 93 | + # and formally soft-deprecated in 3.15+. We |
| 94 | + # we skip the test rather than try to fix it |
| 95 | + # (which would risk breaking other unsupported |
| 96 | + # platforms). |
| 97 | + raise unittest.SkipTest('Fails when ld is mold') |
| 98 | + |
78 | 99 | def test_find_on_libpath(self): |
79 | | - import subprocess |
80 | 100 | import tempfile |
81 | 101 |
|
82 | 102 | try: |
|