MCPcopy Create free account
hub / github.com/MITK/MITK / mitkPythonBindingsTest

Function mitkPythonBindingsTest

Modules/Python/test/mitkPythonBindingsTest.cpp:68–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68int 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}

Callers

nothing calls this directly

Calls 5

EnsurePytestInstalledFunction · 0.85
ExecuteFileMethod · 0.80
ActivateMethod · 0.45
GetDescriptionMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected