diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 0015282..dc9abf7 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -55,7 +55,7 @@ jobs: strategy: fail-fast: false matrix: - - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: Checkout repository diff --git a/src/brainreg/backend/niftyreg/niftyreg_binaries.py b/src/brainreg/backend/niftyreg/niftyreg_binaries.py index 0230c6e..0f9b4a0 100644 --- a/src/brainreg/backend/niftyreg/niftyreg_binaries.py +++ b/src/brainreg/backend/niftyreg/niftyreg_binaries.py @@ -67,8 +67,8 @@ def get_binary(program_name: str) -> Path: bin_path = packaged_binaries_folder / os_folder_name / program_name # Append exe label to Windows executables - # It looks like subprocess is actually able to cope without the .exe appended, - # but just to be safe we'll include it on Windows OS calls + # It looks like subprocess is actually able to cope without the .exe + # appended, but just to be safe we'll include it on Windows OS calls if _IS_WINDOWS_OS: bin_path = bin_path.parent / f"{bin_path.stem}.exe" return bin_path diff --git a/tests/tests/test_backend/test_niftyreg_detection.py b/tests/tests/test_backend/test_niftyreg_detection.py index 79c4190..d8b54b1 100644 --- a/tests/tests/test_backend/test_niftyreg_detection.py +++ b/tests/tests/test_backend/test_niftyreg_detection.py @@ -13,11 +13,12 @@ def packaged_binaries_are_used() -> Tuple[bool, Path]: """ Return a (bool, Path) tuple which has the values: boolean: - TRUE if the get_binary function points to one of the niftyreg binaries - that are included with the package. + TRUE if the get_binary function points to one of the niftyreg + binaries that are included with the package. FALSE otherwise. Path: - The path to the folder containing the niftyreg binaries that were found + The path to the folder containing the niftyreg binaries that + were found. """ using_binary = get_binary("reg_aladin") return ( @@ -29,21 +30,34 @@ def packaged_binaries_are_used() -> Tuple[bool, Path]: def test_conda_with_niftyreg(): """ Check the following: - - If we are not in a conda environment, the packaged niftyreg binaries are used by the backend - - If we are in a conda environment and niftyreg is not conda-installed, the packaged niftyreg binaries are used by the backend - - If we are in a conda environment and niftyreg IS conda-installed, the conda-installed binaries are used by the backend. + - If we are not in a conda environment, the packaged niftyreg binaries + are used by the backend + - If we are in a conda environment and niftyreg is not conda-installed, + the packaged niftyreg binaries are used by the backend + - If we are in a conda environment and niftyreg IS conda-installed, + the conda-installed binaries are used by the backend. + + We need the assert_msg's to get round mypy thinking we're passing tuples + to assert (since Tuples always evaluate to true, and mypy wants to split + long code lines). """ if "CONDA_PREFIX" not in os.environ: # We are not in a conda envrionment # _CONDA_NIFTYREG_BINARY_PATH should be none - assert ( - _CONDA_NIFTYREG_BINARY_PATH is None - ), f"Not in a conda environment but _CONDA_NIFTYREG_BINARY_PATH is non-None: {_CONDA_NIFTYREG_BINARY_PATH}" + assert_msg = ( + "Not in a conda environment but " + "_CONDA_NIFTYREG_BINARY_PATH is non-None: " + f"{_CONDA_NIFTYREG_BINARY_PATH}" + ) + assert _CONDA_NIFTYREG_BINARY_PATH is None, assert_msg using_packaged_binaries, bin_folder = packaged_binaries_are_used() - assert ( - using_packaged_binaries - ), f"There is no CONDA_PREFIX, but non-packaged binaries in {bin_folder} are being used!" + assert_msg = ( + "There is no CONDA_PREFIX, " + f"but non-packaged binaries in {bin_folder} " + "are being used!" + ) + assert using_packaged_binaries, assert_msg else: # We are in a conda environment. # Either this environment does not have niftyreg installed, or it does. @@ -51,9 +65,19 @@ def test_conda_with_niftyreg(): # Apparently niftyreg is not installed in this environment # Assert the located binaries are the packaged ones using_packaged_binaries, bin_folder = packaged_binaries_are_used() - assert using_packaged_binaries, f"Conda environment without niftyreg installed exists, but non-packaged binaries in {bin_folder} are being used." + assert_msg = ( + "Conda environment without niftyreg installed exists, " + f"but non-packaged binaries in {bin_folder} " + "are being used." + ) + assert using_packaged_binaries, assert_msg else: # We are in a conda environment that _has_ niftyreg conda-installed # Assert that we are using the CONDA-installed binaries using_packaged_binaries, bin_folder = packaged_binaries_are_used() - assert not using_packaged_binaries, f"Packaged binaries are being used despite appearing to be installed by CONDA at {_CONDA_NIFTYREG_BINARY_PATH}" + assert_msg = ( + "Packaged binaries are being used, " + "despite niftyreg appearing to be installed by CONDA " + f" at {_CONDA_NIFTYREG_BINARY_PATH}" + ) + assert not using_packaged_binaries, assert_msg