Skip to content

Commit 600d361

Browse files
authored
Merge pull request #69 from dwhswenson/include-tests-coverage
Stop excluding tests from coverage
2 parents f9cd13d + f0d946b commit 600d361

File tree

15 files changed

+54
-45
lines changed

15 files changed

+54
-45
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[report]
22
omit =
3-
*/paths_cli/tests/*
43
*/paths_cli/_installed_version.py
54
*/paths_cli/version.py
65
exclude_lines =

paths_cli/compiling/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class InstanceCompilerPlugin(OPSPlugin):
153153
"""
154154
SCHEMA = "http://openpathsampling.org/schemas/sim-setup/draft01.json"
155155
category = None
156-
156+
157157
def __init__(self, builder, parameters, name=None, *, aliases=None,
158158
description=None, requires_ops=(1, 0),
159159
requires_cli=(0, 3)):

paths_cli/tests/commands/test_md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_md_main(md_fixture, inp):
159159
nsteps, ensembles = 5, None
160160
elif inp == 'ensemble':
161161
nsteps, ensembles = None, [ens]
162-
else:
162+
else: # -no-cov-
163163
raise RuntimeError("pytest went crazy")
164164

165165
traj, foo = md_main(

paths_cli/tests/commands/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import traceback
22

33
def assert_click_success(result):
4-
if result.exit_code != 0:
4+
if result.exit_code != 0: # -no-cov- (only occurs on test error)
55
print(result.output)
66
traceback.print_tb(result.exc_info[2])
77
print(result.exc_info[0], result.exc_info[1])

paths_cli/tests/compiling/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def _validate_obj(obj, input_type):
332332
assert obj == 'bar'
333333
elif input_type == 'dict':
334334
assert obj.data == 'qux'
335-
else:
335+
else: # -no-cov-
336336
raise RuntimeError("Error in test setup")
337337

338338
@pytest.mark.parametrize('input_type', ['str', 'dict'])

paths_cli/tests/compiling/test_volumes.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import pytest
22
from unittest import mock
33
from paths_cli.tests.compiling.utils import mock_compiler
4+
from paths_cli.compiling.plugins import CVCompilerPlugin
5+
from paths_cli.compiling.core import Parameter
46

57
import yaml
68
import numpy as np
@@ -23,20 +25,20 @@ def setup(self):
2325
}
2426

2527
self.func = {
26-
'inline': "\n ".join(["name: foo", "type: mdtraj"]),
28+
'inline': "\n " + "\n ".join([
29+
"name: foo",
30+
"type: fake_type",
31+
"input_data: bar",
32+
]),
2733
'external': 'foo'
2834
}
2935

30-
def create_inputs(self, inline, periodic):
31-
yml = "\n".join(["type: cv-volume", "cv: {func}",
32-
"lambda_min: 0", "lambda_max: 1"])
33-
3436
def set_periodic(self, periodic):
3537
if periodic == 'periodic':
3638
self.named_objs_dict['foo']['period_max'] = 'np.pi'
3739
self.named_objs_dict['foo']['period_min'] = '-np.pi'
3840

39-
@pytest.mark.parametrize('inline', ['external', 'external'])
41+
@pytest.mark.parametrize('inline', ['external', 'inline'])
4042
@pytest.mark.parametrize('periodic', ['periodic', 'nonperiodic'])
4143
def test_build_cv_volume(self, inline, periodic):
4244
self.set_periodic(periodic)
@@ -47,14 +49,29 @@ def test_build_cv_volume(self, inline, periodic):
4749
mock_cv = CoordinateFunctionCV(lambda s: s.xyz[0][0],
4850
period_min=period_min,
4951
period_max=period_max).named('foo')
52+
53+
patch_loc = 'paths_cli.compiling.root_compiler._COMPILERS'
54+
5055
if inline =='external':
51-
patch_loc = 'paths_cli.compiling.root_compiler._COMPILERS'
5256
compilers = {
5357
'cv': mock_compiler('cv', named_objs={'foo': mock_cv})
5458
}
55-
with mock.patch.dict(patch_loc, compilers):
56-
vol = build_cv_volume(dct)
57-
elif inline == 'internal':
59+
elif inline == 'inline':
60+
fake_plugin = CVCompilerPlugin(
61+
name="fake_type",
62+
parameters=[Parameter('input_data', str)],
63+
builder=lambda input_data: mock_cv
64+
)
65+
compilers = {
66+
'cv': mock_compiler(
67+
'cv',
68+
type_dispatch={'fake_type': fake_plugin}
69+
)
70+
}
71+
else: # -no-cov-
72+
raise RuntimeError("Should never get here")
73+
74+
with mock.patch.dict(patch_loc, compilers):
5875
vol = build_cv_volume(dct)
5976

6077
in_state = make_1d_traj([0.5])[0]

paths_cli/tests/test_file_copying.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def __init__(self):
5959
self.previously_seen = set([])
6060

6161
def __call__(self, snap):
62-
if snap in self.previously_seen:
62+
if snap in self.previously_seen: # -no-cov-
63+
# this is only covered if an error occurs
6364
raise AssertionError("Second CV eval for " + str(snap))
6465
self.previously_seen.update({snap})
6566
return snap.xyz[0][0]

paths_cli/tests/test_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _filename(self, getter):
103103

104104
def create_file(self, getter):
105105
filename = self._filename(getter)
106-
if getter == "named":
106+
if getter == "name":
107107
self.other_scheme = self.other_scheme.named("other")
108108
self.other_engine = self.other_engine.named("other")
109109

paths_cli/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_len(self):
1010
def test_empty(self):
1111
ordered = OrderedSet()
1212
assert len(ordered) == 0
13-
for _ in ordered:
13+
for _ in ordered: # -no-cov-
1414
raise RuntimeError("This should not happen")
1515

1616
def test_order(self):

paths_cli/tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
try:
55
urllib.request.urlopen('https://www.google.com')
6-
except:
6+
except: # -no-cov-
77
HAS_INTERNET = False
88
else:
99
HAS_INTERNET = True
1010

1111
def assert_url(url):
12-
if not HAS_INTERNET:
12+
if not HAS_INTERNET: # -no-cov-
1313
pytest.skip("Internet connection seems faulty")
1414

1515
# TODO: On a 404 this will raise a urllib.error.HTTPError. It would be

0 commit comments

Comments
 (0)