summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-10-29 10:15:30 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-03 10:16:38 +0100
commit6283c5aebf34c833c7f79c1e3c21cf3764dc1edd (patch)
treeab7e58080c2667695b0e1eee0e7531d9222483c9 /tests
parent72f0f50ada9cafc586e1642259769d5bd9564bd5 (diff)
downloadpylint-git-6283c5aebf34c833c7f79c1e3c21cf3764dc1edd.tar.gz
Add test for current pyproject issuesinvalid-toml-config
Diffstat (limited to 'tests')
-rw-r--r--tests/config/file_to_lint.py1
-rw-r--r--tests/config/issue_4580/1.toml2
-rw-r--r--tests/config/issue_4580/2.toml2
-rw-r--r--tests/config/issue_4580/3.toml2
-rw-r--r--tests/config/issue_4746/pyproject.toml7
-rw-r--r--tests/config/test_config_pyproject_toml.py35
6 files changed, 49 insertions, 0 deletions
diff --git a/tests/config/file_to_lint.py b/tests/config/file_to_lint.py
new file mode 100644
index 000000000..e4c380d27
--- /dev/null
+++ b/tests/config/file_to_lint.py
@@ -0,0 +1 @@
+"""Perfect module with only documentation for test_config_pyproject_toml.py"""
diff --git a/tests/config/issue_4580/1.toml b/tests/config/issue_4580/1.toml
new file mode 100644
index 000000000..1b291b355
--- /dev/null
+++ b/tests/config/issue_4580/1.toml
@@ -0,0 +1,2 @@
+[tool.pylint]
+load-plugins = []
diff --git a/tests/config/issue_4580/2.toml b/tests/config/issue_4580/2.toml
new file mode 100644
index 000000000..2f8fdb555
--- /dev/null
+++ b/tests/config/issue_4580/2.toml
@@ -0,0 +1,2 @@
+[tool.pylint.imports]
+preferred-modules = { "a"="b" }
diff --git a/tests/config/issue_4580/3.toml b/tests/config/issue_4580/3.toml
new file mode 100644
index 000000000..845f5e8bb
--- /dev/null
+++ b/tests/config/issue_4580/3.toml
@@ -0,0 +1,2 @@
+[tool.pylint.basic]
+name-group = { "a"="b" }
diff --git a/tests/config/issue_4746/pyproject.toml b/tests/config/issue_4746/pyproject.toml
new file mode 100644
index 000000000..5b41d1b89
--- /dev/null
+++ b/tests/config/issue_4746/pyproject.toml
@@ -0,0 +1,7 @@
+[tool.poe.tasks]
+docs = {cmd = "sphinx-build docs build", help = "Build documentation"}
+
+[tool.pylint.MASTER]
+load-plugins = 'pylint_websockets'
+
+format = ["black", "isort"]
diff --git a/tests/config/test_config_pyproject_toml.py b/tests/config/test_config_pyproject_toml.py
new file mode 100644
index 000000000..bcae5b27b
--- /dev/null
+++ b/tests/config/test_config_pyproject_toml.py
@@ -0,0 +1,35 @@
+from pathlib import Path
+from unittest.mock import patch
+
+import pytest
+
+from pylint import run_pylint
+
+HERE = Path(__file__).parent
+
+
+@pytest.mark.parametrize(
+ "pyproject_toml_path,expected_results",
+ [
+ ["issue_4580", [{"code": 0}, {"code": 0}, {"code": 0}]],
+ [
+ "issue_4746",
+ [{"code": 2, "out": "Plugin 'pylint_websockets' is impossible to load"}],
+ ],
+ ],
+)
+def test_config_pyproject_toml(pyproject_toml_path, expected_results, capsys):
+ pyproject_toml_paths = (HERE / pyproject_toml_path).iterdir()
+ for toml_path, expected_result in zip(pyproject_toml_paths, expected_results):
+ with patch(
+ "sys.argv",
+ ["pylint", "--rcfile", str(toml_path), str(HERE / "file_to_lint.py")],
+ ):
+ try:
+ run_pylint()
+ except SystemExit as ex:
+ out, err = capsys.readouterr()
+ msg = f"Wrong result with configuration {toml_path}"
+ assert expected_result.get("out", "¤") in out or not out, msg
+ assert not err or expected_result.get("err", "¤") in err, msg
+ assert ex.code == expected_result.get("code"), msg