Skip to content

Commit 254d82f

Browse files
authored
[MAINT]: Partially move test_conftest to test__deprecation (#2262)
* Partially move `test_conftest` to `test__deprecation` * Add no cover directive in a comment * Update v0.11.2.rst
1 parent 1c65dca commit 254d82f

File tree

3 files changed

+53
-44
lines changed

3 files changed

+53
-44
lines changed

docs/sphinx/source/whatsnew/v0.11.2.rst

+7
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ Requirements
2727
~~~~~~~~~~~~
2828

2929

30+
Maintenance
31+
~~~~~~~~~~~
32+
* Added a decorator to deprecate renamed keyword arguments in functions,
33+
:py:func:`pvlib._deprecation.renamed_kwarg_warning`. (:pull:`2237`)
34+
35+
3036
Contributors
3137
~~~~~~~~~~~~
3238
* Cliff Hansen (:ghuser:`cwhanse`)
3339
* Rajiv Daxini (:ghuser:`RDaxini`)
40+
* Echedey Luis (:ghuser:`echedey-ls`)
3441

pvlib/tests/test__deprecation.py

+46
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,56 @@
55
import pytest
66

77
from pvlib import _deprecation
8+
from .conftest import fail_on_pvlib_version
89

910
import warnings
1011

1112

13+
@pytest.mark.xfail(strict=True,
14+
reason='fail_on_pvlib_version should cause test to fail')
15+
@fail_on_pvlib_version('0.0')
16+
def test_fail_on_pvlib_version():
17+
pass # pragma: no cover
18+
19+
20+
@fail_on_pvlib_version('100000.0')
21+
def test_fail_on_pvlib_version_pass():
22+
pass
23+
24+
25+
@pytest.mark.xfail(strict=True, reason='ensure that the test is called')
26+
@fail_on_pvlib_version('100000.0')
27+
def test_fail_on_pvlib_version_fail_in_test():
28+
raise Exception
29+
30+
31+
# set up to test using fixtures with function decorated with
32+
# conftest.fail_on_pvlib_version
33+
@pytest.fixture
34+
def some_data():
35+
return "some data"
36+
37+
38+
def alt_func(*args):
39+
return args
40+
41+
42+
@pytest.fixture
43+
def deprec_func():
44+
return _deprecation.deprecated(
45+
"350.8", alternative="alt_func", name="deprec_func", removal="350.9"
46+
)(alt_func)
47+
48+
49+
@fail_on_pvlib_version('350.9')
50+
def test_use_fixture_with_decorator(some_data, deprec_func):
51+
# test that the correct data is returned by the some_data fixture
52+
assert some_data == "some data"
53+
with pytest.warns(_deprecation.pvlibDeprecationWarning):
54+
# test for custom deprecation warning provided by pvlib
55+
deprec_func(some_data)
56+
57+
1258
@pytest.fixture
1359
def renamed_kwarg_func():
1460
"""Returns a function decorated by renamed_kwarg_warning.

pvlib/tests/test_conftest.py

-44
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
11
import pytest
2-
import pandas
32

43
from pvlib.tests import conftest
5-
from pvlib.tests.conftest import fail_on_pvlib_version
6-
7-
from pvlib._deprecation import pvlibDeprecationWarning, deprecated
8-
9-
@pytest.mark.xfail(strict=True,
10-
reason='fail_on_pvlib_version should cause test to fail')
11-
@fail_on_pvlib_version('0.0')
12-
def test_fail_on_pvlib_version():
13-
pass
14-
15-
16-
@fail_on_pvlib_version('100000.0')
17-
def test_fail_on_pvlib_version_pass():
18-
pass
19-
20-
21-
@pytest.mark.xfail(strict=True, reason='ensure that the test is called')
22-
@fail_on_pvlib_version('100000.0')
23-
def test_fail_on_pvlib_version_fail_in_test():
24-
raise Exception
25-
26-
27-
# set up to test using fixtures with function decorated with
28-
# conftest.fail_on_pvlib_version
29-
@pytest.fixture()
30-
def some_data():
31-
return "some data"
32-
33-
34-
def alt_func(*args):
35-
return args
36-
37-
38-
deprec_func = deprecated('350.8', alternative='alt_func',
39-
name='deprec_func', removal='350.9')(alt_func)
40-
41-
42-
@fail_on_pvlib_version('350.9')
43-
def test_use_fixture_with_decorator(some_data):
44-
# test that the correct data is returned by the some_data fixture
45-
assert some_data == "some data"
46-
with pytest.warns(pvlibDeprecationWarning): # test for deprecation warning
47-
deprec_func(some_data)
484

495

506
@pytest.mark.parametrize('function_name', ['assert_index_equal',

0 commit comments

Comments
 (0)