Skip to content

Fix test decorator for PyLinter options #5195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions pylint/testutils/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,24 @@ def _forward(self, *args, **test_function_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()
Expand Down
Empty file.