diff --git a/CMakeLists.txt b/CMakeLists.txt index 62bac8e1c9c7d24964d5b8e3b878c7e2ece525de..f17491def53c4e05f09605e5cd4a71afeece5f3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1003,9 +1003,15 @@ if(BUILD_TESTING) string(REGEX REPLACE ".*${TEST}.py::" "" PYTEST ${PYTEST}) add_test( NAME ${TEST}::${PYTEST} + # Without the explicit --rootdir argument, pytest uses + # ${CMAKE_SOURCE_DIR} as root directory. pytest >= 8.0 then tries + # loading ${CMAKE_SOURCE_DIR}/pythondp3/__init__.py and fails, + # since it only works in the the pseudo install directory created + # by pythondp3/CMakeLists.txt. COMMAND python3 -m pytest --exitfirst -v -k ${PYTEST} --junitxml=${CMAKE_BINARY_DIR}/pytest_${TEST}_${PYTEST}.xml + --rootdir=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}.py) set_tests_properties(${TEST}::${PYTEST} PROPERTIES LABELS "${LABELS}") endforeach() @@ -1013,9 +1019,11 @@ if(BUILD_TESTING) # Create one ctest for all sub-tests in a python test file. add_test( NAME ${TEST} + # The comment in add_test above explains why --rootdir is needed. COMMAND python3 -m pytest --exitfirst -v --junitxml=${CMAKE_BINARY_DIR}/pytest_${TEST}.xml + --rootdir=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}.py) set_tests_properties(${TEST} PROPERTIES LABELS "${LABELS}") endif() diff --git a/ddecal/test/integration/tDDECal.py b/ddecal/test/integration/tDDECal.py index 205f55bae4a3cd60eac9eace2a41bc22ff9c4dd1..f1d9e876f712e68f02dc6d591be8cc729f5bdf23 100755 --- a/ddecal/test/integration/tDDECal.py +++ b/ddecal/test/integration/tDDECal.py @@ -731,10 +731,12 @@ def test_dd_solution_intervals(solutions_per_direction): ] try: check_output( - base_command - if solutions_per_direction is None - else base_command - + [f"ddecal.solutions_per_direction={solutions_per_direction}"], + ( + base_command + if solutions_per_direction is None + else base_command + + [f"ddecal.solutions_per_direction={solutions_per_direction}"] + ), stderr=STDOUT, ) except CalledProcessError as e: diff --git a/docker/ubuntu_22_04_base b/docker/ubuntu_22_04_base index ede8c8defa4eff3cdd1a41e8e37c04570f54f113..d1d187757f9228b94471c0a82d3059150a0f15e7 100644 --- a/docker/ubuntu_22_04_base +++ b/docker/ubuntu_22_04_base @@ -78,7 +78,7 @@ RUN wget -nv -O /WSRT_Measures.ztar ftp://ftp.astron.nl/outgoing/Measures/WSRT_M && rm /WSRT_Measures.ztar # Install pip dependencies RUN pip3 install \ - black \ + black~=24.0 \ cmake-format \ h5py \ pytest \