diff options
author | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-10-21 23:50:59 +0200 |
---|---|---|
committer | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-10-21 23:50:59 +0200 |
commit | 43f00e040903e42032e445aaf6ef9c7a9fb028d1 (patch) | |
tree | ab367ca3e084b4ed49e8e2dded6a69b1693e7b78 | |
parent | 3bd397113c7758413dfe50e1b50c1b19a9601327 (diff) | |
download | pylint-git-DanielNoord-patch-1.tar.gz |
Fix decorator for when option is not from ``PyLinter``DanielNoord-patch-1
-rw-r--r-- | pylint/testutils/decorator.py | 23 | ||||
-rw-r--r-- | tests/testutils/dummy_checker.py | 0 |
2 files changed, 18 insertions, 5 deletions
diff --git a/pylint/testutils/decorator.py b/pylint/testutils/decorator.py index eaf72a62a..87fbd7afa 100644 --- a/pylint/testutils/decorator.py +++ b/pylint/testutils/decorator.py @@ -24,11 +24,24 @@ def set_config(**kwargs): except optparse.OptionError: # Check if option is one of the base options of the PyLinter class for key, value in kwargs.items(): - self.checker.set_option( - key.replace("_", "-"), - value, - optdict=dict(PyLinter.make_options())[key.replace("_", "-")], - ) + try: + self.checker.set_option( + key.replace("_", "-"), + value, + optdict=dict(PyLinter.make_options())[ + key.replace("_", "-") + ], + ) + except KeyError: + # pylint: disable-next=fixme + # TODO: Find good way to double load checkers in unittests + # When options are used by multiple checkers we need to load both of them + # to be able to get an optdict + self.checker.set_option( + key.replace("_", "-"), + value, + optdict={}, + ) if isinstance(self, CheckerTestCase): # reopen checker in case, it may be interested in configuration change self.checker.open() diff --git a/tests/testutils/dummy_checker.py b/tests/testutils/dummy_checker.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/testutils/dummy_checker.py |