Skip to content

[MAINT]: Partially move test_conftest to test__deprecation #2262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ Requirements
~~~~~~~~~~~~


Maintenance
~~~~~~~~~~~
* Added a decorator to deprecate renamed keyword arguments in functions,
:py:func:`pvlib._deprecation.renamed_kwarg_warning`. (:pull:`2237`)


Contributors
~~~~~~~~~~~~
* Cliff Hansen (:ghuser:`cwhanse`)
* Rajiv Daxini (:ghuser:`RDaxini`)
* Echedey Luis (:ghuser:`echedey-ls`)

46 changes: 46 additions & 0 deletions pvlib/tests/test__deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,56 @@
import pytest

from pvlib import _deprecation
from .conftest import fail_on_pvlib_version

import warnings


@pytest.mark.xfail(strict=True,
reason='fail_on_pvlib_version should cause test to fail')
@fail_on_pvlib_version('0.0')
def test_fail_on_pvlib_version():
pass # pragma: no cover


@fail_on_pvlib_version('100000.0')
def test_fail_on_pvlib_version_pass():
pass


@pytest.mark.xfail(strict=True, reason='ensure that the test is called')
@fail_on_pvlib_version('100000.0')
def test_fail_on_pvlib_version_fail_in_test():
raise Exception


# set up to test using fixtures with function decorated with
# conftest.fail_on_pvlib_version
@pytest.fixture
def some_data():
return "some data"


def alt_func(*args):
return args


@pytest.fixture
def deprec_func():
return _deprecation.deprecated(
"350.8", alternative="alt_func", name="deprec_func", removal="350.9"
)(alt_func)


@fail_on_pvlib_version('350.9')
def test_use_fixture_with_decorator(some_data, deprec_func):
# test that the correct data is returned by the some_data fixture
assert some_data == "some data"
with pytest.warns(_deprecation.pvlibDeprecationWarning):
# test for custom deprecation warning provided by pvlib
deprec_func(some_data)


@pytest.fixture
def renamed_kwarg_func():
"""Returns a function decorated by renamed_kwarg_warning.
Expand Down
44 changes: 0 additions & 44 deletions pvlib/tests/test_conftest.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
import pytest
import pandas

from pvlib.tests import conftest
from pvlib.tests.conftest import fail_on_pvlib_version

from pvlib._deprecation import pvlibDeprecationWarning, deprecated

@pytest.mark.xfail(strict=True,
reason='fail_on_pvlib_version should cause test to fail')
@fail_on_pvlib_version('0.0')
def test_fail_on_pvlib_version():
pass


@fail_on_pvlib_version('100000.0')
def test_fail_on_pvlib_version_pass():
pass


@pytest.mark.xfail(strict=True, reason='ensure that the test is called')
@fail_on_pvlib_version('100000.0')
def test_fail_on_pvlib_version_fail_in_test():
raise Exception


# set up to test using fixtures with function decorated with
# conftest.fail_on_pvlib_version
@pytest.fixture()
def some_data():
return "some data"


def alt_func(*args):
return args


deprec_func = deprecated('350.8', alternative='alt_func',
name='deprec_func', removal='350.9')(alt_func)


@fail_on_pvlib_version('350.9')
def test_use_fixture_with_decorator(some_data):
# test that the correct data is returned by the some_data fixture
assert some_data == "some data"
with pytest.warns(pvlibDeprecationWarning): # test for deprecation warning
deprec_func(some_data)


@pytest.mark.parametrize('function_name', ['assert_index_equal',
Expand Down