| 66 | } |
| 67 | |
| 68 | int mitkPythonBindingsTest(int, char*[]) |
| 69 | { |
| 70 | MITK_TEST_BEGIN("mitkPythonBindingsTest") |
| 71 | |
| 72 | const fs::path pytestRunner = fs::path(MITK_PYTHON_PYTEST_RUNNER); |
| 73 | MITK_TEST_CONDITION_REQUIRED(fs::exists(pytestRunner), "Pytest runner script exists in the source tree") |
| 74 | |
| 75 | mitk::PythonContext pythonContext("mitk_pytest"); |
| 76 | |
| 77 | EnsurePytestInstalled(); |
| 78 | |
| 79 | bool activateOk = true; |
| 80 | try { pythonContext.Activate(); } |
| 81 | catch (const mitk::Exception& e) { MITK_ERROR << e.GetDescription(); activateOk = false; } |
| 82 | MITK_TEST_CONDITION_REQUIRED(activateOk, "Python context activated (numpy + mitk importable)") |
| 83 | |
| 84 | bool setDataDirOk = true; |
| 85 | try |
| 86 | { |
| 87 | pythonContext.Execute("_mitk_data_dir = '" + std::string(MITK_DATA_DIR) + "'"); |
| 88 | } |
| 89 | catch (const mitk::Exception& e) { MITK_ERROR << e.GetDescription(); setDataDirOk = false; } |
| 90 | MITK_TEST_CONDITION_REQUIRED(setDataDirOk, "Exposed MITK test data directory to the Python binding tests") |
| 91 | |
| 92 | bool pytestOk = true; |
| 93 | try { pythonContext.ExecuteFile(pytestRunner); } |
| 94 | catch (const mitk::Exception& e) { MITK_ERROR << e.GetDescription(); pytestOk = false; } |
| 95 | MITK_TEST_CONDITION_REQUIRED(pytestOk, "pytest suite passed") |
| 96 | |
| 97 | MITK_TEST_END() |
| 98 | } |
nothing calls this directly
no test coverage detected