| 84 | |
| 85 | |
| 86 | def test_f2py_init_compile_bad_cmd(): |
| 87 | # verify that usage of invalid command in f2py.compile() returns |
| 88 | # status value of 127 for historic consistency with exec_command() |
| 89 | # error handling |
| 90 | |
| 91 | # patch the sys Python exe path temporarily to induce an OSError |
| 92 | # downstream NOTE: how bad of an idea is this patching? |
| 93 | try: |
| 94 | temp = sys.executable |
| 95 | sys.executable = "does not exist" |
| 96 | |
| 97 | # the OSError should take precedence over invalid Fortran |
| 98 | ret_val = numpy.f2py.compile(b"invalid") |
| 99 | assert ret_val == 127 |
| 100 | finally: |
| 101 | sys.executable = temp |
| 102 | |
| 103 | |
| 104 | @pytest.mark.parametrize( |