8000 fix fail_on_pvlib_version decorator does not run code when pass expec… · aliyevsultan/pvlib-python@f8bbf95 · GitHub
[go: up one dir, main page]

Skip to content

Commit f8bbf95

Browse files
authored
fix fail_on_pvlib_version decorator does not run code when pass expected (pvlib#574)
* fix fail_on_pvlib_version decorator does not run code when pass expected * apply ci fixes from sattilt * update test code percentage
1 parent dabdeaf commit f8bbf95

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

.codecov.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ coverage:
66
status:
77
patch:
88
default:
9-
target: '80'
9+
target: 100%
1010
if_no_uploads: error
1111
if_not_found: success
1212
if_ci_failed: failure
@@ -19,10 +19,9 @@ coverage:
1919
if_ci_failed: failure
2020
paths:
2121
- "pvlib/(\w+/)?[^/]+\.py$"
22-
2322
tests:
24-
target: 100%
23+
target: 96%
2524
paths:
26-
- "pvlib/tests/.*"
25+
- "pvlib/test/.*"
2726

2827
comment: off

.stickler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ linters:
22
flake8:
33
python: 3
44
max-line-length: 79
5+
ignore: E201,E241
56
files:
67
ignore:
78
- 'pvlib/_version.py'

pvlib/test/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# decorator takes one argument: the base version for which it should fail
1515
# for example @fail_on_pvlib_version('0.7') will cause a test to fail
1616
# on pvlib versions 0.7a, 0.7b, 0.7rc1, etc.
17+
# test function may not take args, kwargs, or fixtures.
1718
def fail_on_pvlib_version(version):
1819
# second level of decorator takes the function under consideration
1920
def wrapper(func):
@@ -27,7 +28,7 @@ def inner():
2728
'removed in %s' % version)
2829
# otherwise return the function to be executed
2930
else:
30-
return func
31+
return func()
3132
return inner
3233
return wrapper
3334

pvlib/test/test_conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ def test_fail_on_pvlib_version():
1414
@fail_on_pvlib_version('100000.0')
1515
def test_fail_on_pvlib_version_pass():
1616
pass
17+
18+
19+
@pytest.mark.xfail(strict=(not (platform_is_windows and has_python2)),
20+
reason='ensure that the test is called')
21+
@fail_on_pvlib_version('100000.0')
22+
def test_fail_on_pvlib_version_fail_in_test():
23+
raise Exception

pvlib/test/test_modelchain.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ def poadc(mc):
219219

220220
@pytest.mark.parametrize('dc_model', [
221221
'sapm',
222-
pytest.param('cec', marks=requires_scipy),
223-
pytest.param('desoto', marks=requires_scipy),
224-
pytest.param('pvsyst', marks=requires_scipy),
225-
pytest.param('singlediode', marks=requires_scipy),
222+
pytest.param('cec', marks=requires_scipy),
223+
pytest.param('desoto', marks=requires_scipy),
224+
pytest.param('pvsyst', marks=requires_scipy),
225+
pytest.param('singlediode', marks=requires_scipy),
226226
'pvwatts_dc'])
227227
def test_infer_dc_model(system, cec_dc_snl_ac_system, pvsyst_dc_snl_ac_system,
228228
pvwatts_dc_pvwatts_ac_system, location, dc_model,
@@ -445,9 +445,12 @@ def test_bad_get_orientation():
445445

446446
@fail_on_pvlib_version('0.7')
447447
def test_deprecated_07():
448+
# explicit system creation call because fail_on_pvlib_version
449+
# does not support decorators
450+
system = cec_dc_snl_ac_system(sam_data())
448451
with pytest.warns(pvlibDeprecationWarning):
449-
mc = ModelChain(cec_dc_snl_ac_system, location,
450-
dc_model='singlediode', # this should fail after 0.7
452+
mc = ModelChain(system, location,
453+
dc_model='singlediode', # this should fail after 0.7
451454
aoi_model='no_loss', spectral_model='no_loss')
452455

453456

0 commit comments

Comments
 (0)
0