diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-12-13 13:41:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-13 13:41:35 +0100 |
commit | ee60bc1ae9a2f5329f7649dd4aa4fdad09587afa (patch) | |
tree | 80ee8adaa0f00aef300416b2f6b7248372e15b6a | |
parent | df99320cae2f0727c8e105a326d2d307b7d42a7d (diff) | |
download | pylint-git-ee60bc1ae9a2f5329f7649dd4aa4fdad09587afa.tar.gz |
Add a DeprecationWarning to set_config_directly (#5511)
-rw-r--r-- | pylint/testutils/decorator.py | 9 | ||||
-rw-r--r-- | tests/testutils/test_decorator.py | 15 |
2 files changed, 24 insertions, 0 deletions
diff --git a/pylint/testutils/decorator.py b/pylint/testutils/decorator.py index 87fbd7afa..4cee70302 100644 --- a/pylint/testutils/decorator.py +++ b/pylint/testutils/decorator.py @@ -3,6 +3,7 @@ import functools import optparse # pylint: disable=deprecated-module +import warnings from pylint.lint import PyLinter from pylint.testutils.checker_test_case import CheckerTestCase @@ -63,6 +64,14 @@ def set_config_directly(**kwargs): Passing the args and kwargs back to the test function itself allows this decorator to be used on parametrized test cases. """ + # pylint: disable=fixme + # TODO: Remove this function in 2.14 + warnings.warn( + "The set_config_directly decorator will be removed in 2.14. To decorate " + "unittests you can use set_config. If this causes a duplicate KeyError " + "you can consider writing the tests using the functional test framework.", + DeprecationWarning, + ) def _wrapper(fun): @functools.wraps(fun) diff --git a/tests/testutils/test_decorator.py b/tests/testutils/test_decorator.py new file mode 100644 index 000000000..0bd1fb119 --- /dev/null +++ b/tests/testutils/test_decorator.py @@ -0,0 +1,15 @@ +# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE + + +import pytest + +from pylint.testutils.decorator import set_config_directly + + +def test_deprecation_of_set_config_directly() -> None: + """Test that the deprecation of set_config_directly works as expected""" + + with pytest.warns(DeprecationWarning) as records: + set_config_directly() + assert len(records) == 1 |