Test the mingw32ccompiler.build_import_library, which builds a `python.a` from the MSVC `python.lib`
()
| 8 | |
| 9 | @pytest.mark.skipif(sys.platform != 'win32', reason='win32 only test') |
| 10 | def test_build_import(): |
| 11 | '''Test the mingw32ccompiler.build_import_library, which builds a |
| 12 | `python.a` from the MSVC `python.lib` |
| 13 | ''' |
| 14 | |
| 15 | # make sure `nm.exe` exists and supports the current python version. This |
| 16 | # can get mixed up when the PATH has a 64-bit nm but the python is 32-bit |
| 17 | try: |
| 18 | out = subprocess.check_output(['nm.exe', '--help']) |
| 19 | except FileNotFoundError: |
| 20 | pytest.skip("'nm.exe' not on path, is mingw installed?") |
| 21 | supported = out[out.find(b'supported targets:'):] |
| 22 | if sys.maxsize < 2**32: |
| 23 | if b'pe-i386' not in supported: |
| 24 | raise ValueError("'nm.exe' found but it does not support 32-bit " |
| 25 | "dlls when using 32-bit python. Supported " |
| 26 | "formats: '%s'" % supported) |
| 27 | elif b'pe-x86-64' not in supported: |
| 28 | raise ValueError("'nm.exe' found but it does not support 64-bit " |
| 29 | "dlls when using 64-bit python. Supported " |
| 30 | "formats: '%s'" % supported) |
| 31 | # Hide the import library to force a build |
| 32 | has_import_lib, fullpath = mingw32ccompiler._check_for_import_lib() |
| 33 | if has_import_lib: |
| 34 | shutil.move(fullpath, fullpath + '.bak') |
| 35 | |
| 36 | try: |
| 37 | # Whew, now we can actually test the function |
| 38 | mingw32ccompiler.build_import_library() |
| 39 | |
| 40 | finally: |
| 41 | if has_import_lib: |
| 42 | shutil.move(fullpath + '.bak', fullpath) |
nothing calls this directly
no test coverage detected