Skip to content

Commit ee60bc1

Browse files
authored
Add a DeprecationWarning to set_config_directly (#5511)
1 parent df99320 commit ee60bc1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pylint/testutils/decorator.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import functools
55
import optparse # pylint: disable=deprecated-module
6+
import warnings
67

78
from pylint.lint import PyLinter
89
from pylint.testutils.checker_test_case import CheckerTestCase
@@ -63,6 +64,14 @@ def set_config_directly(**kwargs):
6364
Passing the args and kwargs back to the test function itself
6465
allows this decorator to be used on parametrized test cases.
6566
"""
67+
# pylint: disable=fixme
68+
# TODO: Remove this function in 2.14
69+
warnings.warn(
70+
"The set_config_directly decorator will be removed in 2.14. To decorate "
71+
"unittests you can use set_config. If this causes a duplicate KeyError "
72+
"you can consider writing the tests using the functional test framework.",
73+
DeprecationWarning,
74+
)
6675

6776
def _wrapper(fun):
6877
@functools.wraps(fun)

tests/testutils/test_decorator.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2+
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
3+
4+
5+
import pytest
6+
7+
from pylint.testutils.decorator import set_config_directly
8+
9+
10+
def test_deprecation_of_set_config_directly() -> None:
11+
"""Test that the deprecation of set_config_directly works as expected"""
12+
13+
with pytest.warns(DeprecationWarning) as records:
14+
set_config_directly()
15+
assert len(records) == 1

0 commit comments

Comments
 (0)