Skip to content

Commit 9a0f0ea

Browse files
basaksMatt Garthwaite
authored and
Matt Garthwaite
committed
add a coverage rc, workflow test, pragmas
1 parent 7f4b9d5 commit 9a0f0ea

File tree

7 files changed

+80
-8
lines changed

7 files changed

+80
-8
lines changed

.coveragerc

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# .coveragerc to control coverage.py
2+
[run]
3+
branch = True
4+
source = pyrate
5+
#omit =
6+
# omit everything in
7+
# pyrate/tasks/*
8+
# omit these files
9+
# pyrate/pyratelog.py
10+
# pyrate/scripts/main.py
11+
# pyrate/pyaps.py
12+
# pyrate/compat.py
13+
14+
[report]
15+
# Regexes for lines to exclude from consideration
16+
exclude_lines =
17+
# Have to re-enable the standard pragma
18+
pragma: no cover
19+
20+
# Don't complain about missing debug-only code:
21+
def __repr__
22+
def __str__
23+
if self\.debug
24+
25+
# Don't complain if tests don't hit defensive assertion code:
26+
raise AssertionError
27+
raise NotImplementedError
28+
raise ValueError
29+
raise RuntimeError
30+
raise IOError
31+
except OSError
32+
except ValueError
33+
except IndexError
34+
raise ImportError
35+
except ImportError
36+
raise ConfigException
37+
raise ReferencePhaseError
38+
raise RefPixelError
39+
raise RoipacException
40+
raise GeotiffException
41+
raise RasterException
42+
raise IfgException
43+
raise GammaException
44+
raise PreprocessError
45+
raise TimeSeriesError
46+
raise OrbitalError
47+
48+
# Don't complain if non-runnable code isn't run:
49+
if 0:
50+
if __name__ == .__main__.:
51+
52+
ignore_errors = True
53+
54+
[html]
55+
directory = coverage_html_report

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ install:
6060
script:
6161
# - python scripts/update_placeholder_paths.py
6262
- mpirun -n 3 pytest tests/test_mpi.py
63-
- pytest --cov-report term-missing:skip-covered --cov=pyrate tests/
63+
- pytest --cov-config=.coveragerc --cov-report term-missing:skip-covered --cov=pyrate tests/
6464

6565

6666
after_success:

pyrate/configuration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __init__(self, config_file_path):
130130
PYRATE_DEFAULT_CONFIGRATION[parameter_name]["PossibleValues"])
131131

132132
# bespoke parameter validation
133-
if self.refchipsize % 2 != 1:
133+
if self.refchipsize % 2 != 1: # pragma: no cover
134134
if self.refchipsize - 1 > 1:
135135
# Configuration parameters refchipsize must be odd
136136
# values too large (>101) will slow down the process without significant gains in results.

pyrate/core/prepifg_helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from numbers import Number
2828
from subprocess import check_call
2929
from tempfile import mkstemp
30-
30+
from decimal import Decimal
3131

3232
from numpy import array, where, nan, isnan, nanmean, float32, zeros, \
3333
sum as nsum
@@ -348,7 +348,7 @@ def _max_bounds(ifgs):
348348
ymin = min([i.y_last for i in ifgs])
349349
return xmin, ymin, xmax, ymax
350350

351-
from decimal import Decimal
351+
352352
def _get_same_bounds(ifgs):
353353
"""
354354
Check and return bounding box for ALREADY_SAME_SIZE option.

pyrate/main.py

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ def main():
116116
prepifg.main(params)
117117

118118
log.info("***********PROCESS**************")
119+
120+
# reset params as prepifg modifies params
121+
params = _params_from_conf(args.config_file)
119122
process.main(params)
120123

121124
log.info("***********MERGE**************")

tests/conftest.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ def roipac_or_gamma_conf(request):
103103
return request.param
104104

105105

106-
@pytest.fixture(params=[TEST_CONF_GAMMA], scope='session')
106+
@pytest.fixture(params=[TEST_CONF_GAMMA])
107107
def gamma_conf(request):
108-
return request.param
108+
params = Configuration(TEST_CONF_GAMMA).__dict__
109+
yield request.param
110+
shutil.rmtree(params[cf.OUT_DIR])
109111

110112

111113
@pytest.fixture

tests/test_system.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
17+
1718
"""
18-
This Python module contains tests for mpi operations in PyRate.
19-
Tun this module as 'mpirun -n 4 pytest tests/test_mpi.py'
19+
pyrate basic workflow for all supported input datasets
20+
2021
"""
2122
from subprocess import check_call
2223
from pathlib import Path
@@ -37,3 +38,14 @@ def test_workflow(system_conf):
3738
log_file_name = 'pyrate.log.' + stage
3839
files = list(Path(params[cf.OUT_DIR]).glob(log_file_name + '.*'))
3940
assert len(files) == 1
41+
42+
43+
def test_single_workflow(gamma_conf):
44+
45+
check_call(f"pyrate workflow -f {gamma_conf}", shell=True)
46+
47+
params = Configuration(gamma_conf).__dict__
48+
49+
log_file_name = 'pyrate.log.' + 'workflow'
50+
files = list(Path(params[cf.OUT_DIR]).glob(log_file_name + '.*'))
51+
assert len(files) == 1

0 commit comments

Comments
 (0)