From 5ed81578e927afe25f965e19ced3758526be12a8 Mon Sep 17 00:00:00 2001 From: Will Holmgren Date: Tue, 11 Sep 2018 20:29:43 -0700 Subject: [PATCH 1/3] fix fail_on_pvlib_version decorator does not run code when pass expected --- pvlib/test/conftest.py | 3 ++- pvlib/test/test_conftest.py | 7 +++++++ pvlib/test/test_modelchain.py | 15 +++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pvlib/test/conftest.py b/pvlib/test/conftest.py index a249953858..914eadd007 100644 --- a/pvlib/test/conftest.py +++ b/pvlib/test/conftest.py @@ -14,6 +14,7 @@ # decorator takes one argument: the base version for which it should fail # for example @fail_on_pvlib_version('0.7') will cause a test to fail # on pvlib versions 0.7a, 0.7b, 0.7rc1, etc. +# test function may not take args, kwargs, or fixtures. def fail_on_pvlib_version(version): # second level of decorator takes the function under consideration def wrapper(func): @@ -27,7 +28,7 @@ def inner(): 'removed in %s' % version) # otherwise return the function to be executed else: - return func + return func() return inner return wrapper diff --git a/pvlib/test/test_conftest.py b/pvlib/test/test_conftest.py index 57048f421c..e2a836537c 100644 --- a/pvlib/test/test_conftest.py +++ b/pvlib/test/test_conftest.py @@ -14,3 +14,10 @@ def test_fail_on_pvlib_version(): @fail_on_pvlib_version('100000.0') def test_fail_on_pvlib_version_pass(): pass + + +@pytest.mark.xfail(strict=(not (platform_is_windows and has_python2)), + reason='ensure that the test is called') +@fail_on_pvlib_version('100000.0') +def test_fail_on_pvlib_version_fail_in_test(): + raise Exception diff --git a/pvlib/test/test_modelchain.py b/pvlib/test/test_modelchain.py index e280735db3..703c3879b2 100644 --- a/pvlib/test/test_modelchain.py +++ b/pvlib/test/test_modelchain.py @@ -219,10 +219,10 @@ def poadc(mc): @pytest.mark.parametrize('dc_model', [ 'sapm', - pytest.param('cec', marks=requires_scipy), - pytest.param('desoto', marks=requires_scipy), - pytest.param('pvsyst', marks=requires_scipy), - pytest.param('singlediode', marks=requires_scipy), + pytest.param('cec', marks=requires_scipy), + pytest.param('desoto', marks=requires_scipy), + pytest.param('pvsyst', marks=requires_scipy), + pytest.param('singlediode', marks=requires_scipy), 'pvwatts_dc']) def test_infer_dc_model(system, cec_dc_snl_ac_system, pvsyst_dc_snl_ac_system, pvwatts_dc_pvwatts_ac_system, location, dc_model, @@ -445,9 +445,12 @@ def test_bad_get_orientation(): @fail_on_pvlib_version('0.7') def test_deprecated_07(): + # explicit system creation call because fail_on_pvlib_version + # does not support decorators + system = cec_dc_snl_ac_system(sam_data()) with pytest.warns(pvlibDeprecationWarning): - mc = ModelChain(cec_dc_snl_ac_system, location, - dc_model='singlediode', # this should fail after 0.7 + mc = ModelChain(system, location, + dc_model='singlediode', # this should fail after 0.7 aoi_model='no_loss', spectral_model='no_loss') From f6e13dd737589bf64caad7e06d2c7e4063de706d Mon Sep 17 00:00:00 2001 From: Will Holmgren Date: Tue, 11 Sep 2018 20:32:16 -0700 Subject: [PATCH 2/3] apply ci fixes from sattilt --- .codecov.yml | 5 ++--- .stickler.yml | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 2419fa4db3..1b0a0327aa 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -6,7 +6,7 @@ coverage: status: patch: default: - target: '80' + target: 100% if_no_uploads: error if_not_found: success if_ci_failed: failure @@ -19,10 +19,9 @@ coverage: if_ci_failed: failure paths: - "pvlib/(\w+/)?[^/]+\.py$" - tests: target: 100% paths: - - "pvlib/tests/.*" + - "pvlib/test/.*" comment: off \ No newline at end of file diff --git a/.stickler.yml b/.stickler.yml index 4f97370c49..dfbffa8143 100644 --- a/.stickler.yml +++ b/.stickler.yml @@ -2,6 +2,7 @@ linters: flake8: python: 3 max-line-length: 79 + ignore: E201,E241 files: ignore: - 'pvlib/_version.py' From 060c460ed67f23e46e6b8091fd567de492e15dcc Mon Sep 17 00:00:00 2001 From: Will Holmgren Date: Tue, 11 Sep 2018 20:35:46 -0700 Subject: [PATCH 3/3] update test code percentage --- .codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codecov.yml b/.codecov.yml index 1b0a0327aa..f8a38aff12 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -20,7 +20,7 @@ coverage: paths: - "pvlib/(\w+/)?[^/]+\.py$" tests: - target: 100% + target: 96% paths: - "pvlib/test/.*"