diff options
-rw-r--r-- | pylint/testutils/__init__.py | 3 | ||||
-rw-r--r-- | pylint/testutils/decorator.py | 24 | ||||
-rw-r--r-- | pylint/testutils/utils.py | 19 |
3 files changed, 26 insertions, 20 deletions
diff --git a/pylint/testutils/__init__.py b/pylint/testutils/__init__.py index 5050b631c..5de736071 100644 --- a/pylint/testutils/__init__.py +++ b/pylint/testutils/__init__.py @@ -43,9 +43,10 @@ __all__ = [ ] from pylint.testutils.constants import UPDATE_OPTION +from pylint.testutils.decorator import set_config from pylint.testutils.functional_test_file import FunctionalTestFile from pylint.testutils.get_test_info import _get_tests_info from pylint.testutils.lint_module_test import LintModuleTest from pylint.testutils.output_line import Message from pylint.testutils.reporter_for_tests import GenericTestReporter, MinimalTestReporter -from pylint.testutils.utils import CheckerTestCase, _tokenize_str, linter, set_config +from pylint.testutils.utils import CheckerTestCase, _tokenize_str, linter diff --git a/pylint/testutils/decorator.py b/pylint/testutils/decorator.py new file mode 100644 index 000000000..e10fe066d --- /dev/null +++ b/pylint/testutils/decorator.py @@ -0,0 +1,24 @@ +# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# For details: https://github.com/PyCQA/pylint/blob/master/COPYING + +import functools + +from pylint.testutils.utils import CheckerTestCase + + +def set_config(**kwargs): + """Decorator for setting config values on a checker.""" + + def _wrapper(fun): + @functools.wraps(fun) + def _forward(self): + for key, value in kwargs.items(): + setattr(self.checker.config, key, value) + if isinstance(self, CheckerTestCase): + # reopen checker in case, it may be interested in configuration change + self.checker.open() + fun(self) + + return _forward + + return _wrapper diff --git a/pylint/testutils/utils.py b/pylint/testutils/utils.py index 893bb3e2d..4b2a203a2 100644 --- a/pylint/testutils/utils.py +++ b/pylint/testutils/utils.py @@ -3,7 +3,6 @@ """functional/non regression tests for pylint""" import contextlib -import functools import tokenize from io import StringIO @@ -47,24 +46,6 @@ class UnittestLinter: return linter.options_providers -def set_config(**kwargs): - """Decorator for setting config values on a checker.""" - - def _wrapper(fun): - @functools.wraps(fun) - def _forward(self): - for key, value in kwargs.items(): - setattr(self.checker.config, key, value) - if isinstance(self, CheckerTestCase): - # reopen checker in case, it may be interested in configuration change - self.checker.open() - fun(self) - - return _forward - - return _wrapper - - class CheckerTestCase: """A base testcase class for unit testing individual checker classes.""" |