Fix test decorator for PyLinter options (#5195)

This commit is contained in:
Daniël van Noord 2021-10-22 23:46:36 +02:00 committed by GitHub
parent 259f7a381d
commit 772b3dcc0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -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()),
)
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()

View File