summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-12 09:34:47 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-12 18:00:31 +0100
commitb1f3b41ffd809b52802e40debcf4e6c9bf799fcc (patch)
treeccfab33b6fa5f7229451a9cbffd633e41e7e76b4
parent388a2db19f5685dff4e59a8417d165a954846a88 (diff)
downloadpylint-git-b1f3b41ffd809b52802e40debcf4e6c9bf799fcc.tar.gz
Add a regression test for #4746
This permits to introduce an example of configuration file with an error.
-rw-r--r--pylint/config/option_manager_mixin.py3
-rw-r--r--pylint/testutils/configuration_test.py9
-rw-r--r--tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.out2
-rw-r--r--tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.result.json3
-rw-r--r--tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.toml8
5 files changed, 20 insertions, 5 deletions
diff --git a/pylint/config/option_manager_mixin.py b/pylint/config/option_manager_mixin.py
index 6720bc40e..924998e77 100644
--- a/pylint/config/option_manager_mixin.py
+++ b/pylint/config/option_manager_mixin.py
@@ -271,6 +271,9 @@ class OptionsManagerMixIn:
use_config_file = config_file and os.path.exists(config_file)
if use_config_file:
+ mod_name = config_file
+ self.current_name = mod_name
+ self.set_current_module(mod_name)
parser = self.cfgfile_parser
if config_file.endswith(".toml"):
self._parse_toml(config_file, parser)
diff --git a/pylint/testutils/configuration_test.py b/pylint/testutils/configuration_test.py
index e5a04001d..7000a660c 100644
--- a/pylint/testutils/configuration_test.py
+++ b/pylint/testutils/configuration_test.py
@@ -76,8 +76,8 @@ def get_expected_output(configuration_path: str) -> Tuple[int, str]:
def get_relative_path(path: str) -> str:
"""Get the relative path we want without the user specific path"""
- # Second [1:] is to remove the closing '/'
- return "".join(path.split(USER_SPECIFIC_PATH)[1:][1:])
+ # [1:] is to remove the opening '/'
+ return path.split(USER_SPECIFIC_PATH)[1][1:]
output = get_expected_or_default(configuration_path, suffix="out", default="")
if output:
@@ -91,9 +91,8 @@ def get_expected_output(configuration_path: str) -> Tuple[int, str]:
else:
logging.info(".out file does not exists, so the expected exit code is 0")
exit_code = 0
- return exit_code, output.format(
- abspath=configuration_path, relpath=get_relative_path(configuration_path)
- )
+ relpath = get_relative_path(configuration_path)
+ return exit_code, output.format(abspath=configuration_path, relpath=relpath)
def run_using_a_configuration_file(
diff --git a/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.out b/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.out
new file mode 100644
index 000000000..a6837722a
--- /dev/null
+++ b/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.out
@@ -0,0 +1,2 @@
+************* Module {abspath}
+{relpath}:1:0: E0013: Plugin 'pylint_websockets' is impossible to load, is it installed ? ('No module named 'pylint_websockets'') (bad-plugin-value)
diff --git a/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.result.json b/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.result.json
new file mode 100644
index 000000000..0b6175c4a
--- /dev/null
+++ b/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.result.json
@@ -0,0 +1,3 @@
+{
+ "load_plugins": ["pylint_websockets"]
+}
diff --git a/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.toml b/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.toml
new file mode 100644
index 000000000..ea79aa3a5
--- /dev/null
+++ b/tests/config/functional/toml/issue_4746/loaded_plugin_does_not_exists.toml
@@ -0,0 +1,8 @@
+# The pylint_websockets plugin does not exist and therefore this toml is invalid
+[tool.poe.tasks]
+docs = {cmd = "sphinx-build docs build", help = "Build documentation"}
+
+[tool.pylint.MASTER]
+load-plugins = 'pylint_websockets'
+
+format = ["black", "isort"]