diff --git a/python/__init__.py b/python/__init__.py index ed61a320..91d48fd6 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -2,8 +2,8 @@ import os import sys from . import config -_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..',config.NETGEN_PYTHON_RPATH_BIN)) -_netgen_lib_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..',config.NETGEN_PYTHON_RPATH)) +_netgen_bin_dir=os.path.realpath(os.path.join(config.NG_INSTALL_DIR_PYTHON,config.NETGEN_PYTHON_RPATH_BIN)) +_netgen_lib_dir=os.path.realpath(os.path.join(config.NG_INSTALL_DIR_PYTHON,config.NETGEN_PYTHON_RPATH)) if sys.platform.startswith('win'): if sys.version >= '3.8': diff --git a/tests/pytest/CMakeLists.txt b/tests/pytest/CMakeLists.txt index 26c7d22f..4f7e1c5b 100644 --- a/tests/pytest/CMakeLists.txt +++ b/tests/pytest/CMakeLists.txt @@ -1,8 +1,28 @@ if(USE_PYTHON) - add_test(NAME pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - add_custom_target(pytest ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - set_tests_properties ( pytest PROPERTIES TIMEOUT 1800 ) - if(USE_MPI AND USE_MPI4PY) - add_test(NAME pytest-mpi COMMAND ${MPIEXEC_EXECUTABLE} --allow-run-as-root -np 4 ${PYTHON_EXECUTABLE} -m pytest --with-mpi test_mpi4py.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - endif(USE_MPI AND USE_MPI4PY) + if(ENABLE_UNIT_TESTS) + set(PYTHON_UNIT_TESTS TRUE) + # check for prerequisite modules + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import pytest; print(pytest.__file__)" + OUTPUT_VARIABLE pytest_path RESULT_VARIABLE pytest_result) + if(NOT ${pytest_result} EQUAL 0) + message(WARNING "python module 'pytest' not found.") + set(PYTHON_UNIT_TESTS FALSE) + endif() + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import pytest_check; print(pytest_check.__file__)" + OUTPUT_VARIABLE pycheck_path RESULT_VARIABLE pycheck_result) + if(NOT ${pytest_result} EQUAL 0) + message(WARNING "python module 'pytest_check' not found.") + set(PYTHON_UNIT_TESTS FALSE) + endif() + if(PYTHON_UNIT_TESTS) + add_test(NAME pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_custom_target(pytest ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + set_tests_properties ( pytest PROPERTIES TIMEOUT 18000 ) + if(USE_MPI AND USE_MPI4PY) + add_test(NAME pytest-mpi COMMAND ${MPIEXEC_EXECUTABLE} --allow-run-as-root -np 4 ${PYTHON_EXECUTABLE} -m pytest --with-mpi test_mpi4py.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + endif(USE_MPI AND USE_MPI4PY) + else() + message(WARNING "Unable to perform unit tests on netgen python modules.") + endif() + endif() endif(USE_PYTHON)