Skip to content

Commit c9b53b8

Browse files
replace nose with pytest and attempt to re-add coverage.
Still needs further work on test_algebra.py Added running of coverage to GHA and also upload to coveralls.io.
1 parent 80ccaca commit c9b53b8

File tree

12 files changed

+68
-36
lines changed

12 files changed

+68
-36
lines changed

.coveragerc-Gadgetron

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[run]
2+
data_file = .coverage-Gadgetron
3+
relative_files = True
4+
source = sirf.Gadgetron
5+
[paths]
6+
source =
7+
src/xGadgetron/pGadgetron/
8+
/home/sirfuser/devel/install/python/sirf
9+
/home/runner/install/python/sirf

.coveragerc-Reg

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[run]
2+
data_file = .coverage-Reg
3+
relative_files = True
4+
source = sirf.Reg
5+
[paths]
6+
source =
7+
src/Registration/pReg
8+
/home/sirfuser/devel/install/python/sirf
9+
/home/runner/install/python/sirf

.coveragerc-STIR

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
data_file = .coverage-STIR
3+
relative_files = True
4+
source = sirf.STIR
5+
[paths]
6+
source =
7+
src/xSTIR/pSTIR
8+
/home/sirfuser/devel/install/python/sirf
9+
/home/runner/install/python/sirf
10+

.github/workflows/build-test.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,28 @@ jobs:
115115
cmake --build . -j 2;
116116
- name: tests
117117
shell: bash
118-
run: |
118+
run:
119119
bash -ev ${GITHUB_WORKSPACE}/SIRF-SuperBuild/docker/ctest_sirf.sh
120+
121+
- name: Coverage
122+
shell: bash
123+
run: |
124+
pwd
125+
source ~/virtualenv/bin/activate
126+
coverage combine .coverage-*
127+
coverage report
128+
- name: Coveralls
129+
uses: AndreMiras/coveralls-python-action@develop
130+
with:
131+
parallel: true
132+
flag-name: python test
133+
debug: true
134+
135+
coveralls_finish:
136+
needs: build
137+
runs-on: ubuntu-latest
138+
steps:
139+
- name: Coveralls Finished
140+
uses: AndreMiras/coveralls-python-action@develop
141+
with:
142+
parallel-finished: true

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ errr.txt
270270
output.txt
271271

272272
.coverage
273+
.coverage-*
273274
coverage.xml
274275

275276
*_out.txt

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ scipy --only-binary=scipy
33
matplotlib --only-binary=matplotlib
44
docopt
55
psutil
6-
nose
6+
pytest
7+
pytest-cov
78
deprecation
89
nibabel # optional
+3-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#========================================================================
2-
# Author: Richard Brown
3-
# Copyright 2016-2020 University College London
2+
# Copyright 2016-2022 University College London
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
65
# you may not use this file except in compliance with the License.
@@ -15,15 +14,6 @@
1514
# limitations under the License.
1615
#
1716
#=========================================================================
18-
if (SPM_BOOL_STR EQUAL "0")
19-
set (exclude_tests "--ignore-files=\"test_algebra\"" "--exclude=TestDataContainerAlgebra")
20-
else()
21-
set (exclude_tests "--ignore-files=\"test_algebra\"" "--exclude=TestDataContainerAlgebra")
22-
endif()
23-
# Make into test
2417
ADD_TEST(NAME REG_TESTS_PYTHON
25-
COMMAND ${Python_EXECUTABLE} -m nose --with-coverage --cover-package=sirf.Reg --cover-erase -d -v ${CMAKE_SOURCE_DIR}/src/Registration/pReg ${exclude_tests})
26-
27-
add_test(NAME REG_PYTHON_ALGEBRA
28-
COMMAND ${Python_EXECUTABLE} -m unittest test_algebra
29-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
18+
COMMAND ${Python_EXECUTABLE} -m pytest --cov=sirf.Reg --cov-config=.coveragerc-Reg src/Registration/pReg
19+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

src/common/Utilities.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import sirf.pyiutilities as pyiutil
88
import re
99
from deprecation import deprecated
10+
import pytest
1011

1112
__licence__ = """SyneRBI Synergistic Image Reconstruction Framework (SIRF)
1213
Copyright 2015 - 2021 Rutherford Appleton Laboratory STFC
@@ -594,7 +595,7 @@ def is_operator_adjoint(operator, num_tests = 5, max_err = 10e-5, verbose = True
594595
print("Pass, with a with normalized error of " + str(norm_err) + " (max: " + str(max_err) + ")")
595596
return True
596597

597-
598+
@pytest.mark.skip(reason="This is a base-class for the actual tests")
598599
class TestDataContainerAlgebra(object):
599600

600601
'''A base class for unit test of DataContainer algebra.'''

src/xGadgetron/pGadgetron/tests/CMakeLists.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#========================================================================
22
# Copyright 2017 - 2021 Science Technology Facilities Council
3-
# Copyright 2017 - 2021 University College London
3+
# Copyright 2017 - 2022 University College London
44
#
55
# This file is part of the SyneRBI Synergistic Image Reconstruction Framework (SIRF) SuperBuild.
66
#
@@ -17,16 +17,12 @@
1717
# limitations under the License.
1818
#
1919
#=========================================================================
20-
set (exclude_tests "--ignore-files=\"test_algebra\"" "--exclude=TestDataContainerAlgebra")
2120
add_test(NAME MR_TESTS_PYTHON
22-
COMMAND ${Python_EXECUTABLE} -m nose --with-coverage --cover-package=sirf.Gadgetron src/xGadgetron/pGadgetron/ ${exclude_tests}
21+
COMMAND ${Python_EXECUTABLE} -m pytest --cov=sirf.Gadgetron --cov-config=.coveragerc-Gadgetron src/xGadgetron/pGadgetron/
2322
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
2423
add_test(NAME MR_DEMOS_PYTHON
2524
COMMAND ${Python_EXECUTABLE} run_all.py --non-interactive
2625
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/examples/Python/MR")
2726
add_test(NAME MR_GADGETRON_DEMOS_PYTHON
2827
COMMAND ${Python_EXECUTABLE} run_all.py --non-interactive
2928
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/examples/Python/MR/Gadgetron")
30-
add_test(NAME MR_PYTHON_ALGEBRA
31-
COMMAND ${Python_EXECUTABLE} -m unittest test_algebra
32-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
python_files = test*.py

src/xSTIR/pSTIR/tests/CMakeLists.txt

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#========================================================================
2-
# Copyright 2017 - 2021 University College London
2+
# Copyright 2017 - 2022 University College London
33
# Copyright 2017 - 2021 Science Technology Facilities Council
44
#
55
# This file is part of the SyneRBI Synergistic Image Reconstruction Framework (SIRF) SuperBuild.
@@ -17,22 +17,10 @@
1717
# limitations under the License.
1818
#
1919
#=========================================================================
20-
set (exclude_tests "--ignore-files=\"test_algebra\"" "--exclude=TestDataContainerAlgebra")
21-
# If not NiftyPET projector, dont test that
22-
if (NiftyPET_BOOL_STR EQUAL "0")
23-
set(exclude_tests "--ignore-files=\"test_algebra|tests_NiftyPET\"" "--exclude=TestDataContainerAlgebra")
24-
endif()
2520

2621
add_test(NAME PET_TESTS_PYTHON
27-
COMMAND ${Python_EXECUTABLE} -m nose --with-coverage --cover-package=sirf.STIR src/xSTIR/pSTIR ${exclude_tests}
22+
COMMAND ${Python_EXECUTABLE} -m pytest --cov=sirf.STIR --cov-config=.coveragerc-STIR src/xSTIR/pSTIR
2823
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
2924
#add_test(NAME PET_DEMOS_PYTHON
3025
# COMMAND ${PYTHON_EXECUTABLE} run_all.py --non-interactive
3126
# WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/examples/Python/PET")
32-
add_test(NAME PET_PYTHON_ALGEBRA
33-
COMMAND ${Python_EXECUTABLE} -m unittest test_algebra
34-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
35-
36-
add_test(NAME PET_PYTHON_OBJFUN
37-
COMMAND ${Python_EXECUTABLE} -m unittest test_ObjectiveFunction
38-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

src/xSTIR/pSTIR/tests/pytest.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
python_files = test*.py

0 commit comments

Comments
 (0)