diff options
Diffstat (limited to 'tests/config/test_config_pyproject_toml.py')
-rw-r--r-- | tests/config/test_config_pyproject_toml.py | 35 |
1 files changed, 35 insertions, 0 deletions
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 |