summaryrefslogtreecommitdiff
path: root/tests/testutils
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-12-23 23:02:34 +0100
committerGitHub <noreply@github.com>2021-12-23 23:02:34 +0100
commitb4bf5168621f0a4bf7cca795862e2b5c139fc8cb (patch)
tree9103f50e667e2cdac1cc140938a48b3d8b6c3c04 /tests/testutils
parent1a122dd7c4ace87574440bb78fc9b4ddcbd123d1 (diff)
downloadpylint-git-b4bf5168621f0a4bf7cca795862e2b5c139fc8cb.tar.gz
Create ``_config_initialization`` util and use in functional tests (#5591)
Diffstat (limited to 'tests/testutils')
-rw-r--r--tests/testutils/data/init_hook.py3
-rw-r--r--tests/testutils/data/init_hook.rc3
-rw-r--r--tests/testutils/test_functional_testutils.py21
3 files changed, 27 insertions, 0 deletions
diff --git a/tests/testutils/data/init_hook.py b/tests/testutils/data/init_hook.py
new file mode 100644
index 000000000..f16492d3a
--- /dev/null
+++ b/tests/testutils/data/init_hook.py
@@ -0,0 +1,3 @@
+"""This file should never be tested as the init-hook in the configuration
+file prevents the test runner from getting here.
+"""
diff --git a/tests/testutils/data/init_hook.rc b/tests/testutils/data/init_hook.rc
new file mode 100644
index 000000000..b0efa254b
--- /dev/null
+++ b/tests/testutils/data/init_hook.rc
@@ -0,0 +1,3 @@
+[MASTER]
+
+init-hook=raise RuntimeError
diff --git a/tests/testutils/test_functional_testutils.py b/tests/testutils/test_functional_testutils.py
new file mode 100644
index 000000000..c1e852e15
--- /dev/null
+++ b/tests/testutils/test_functional_testutils.py
@@ -0,0 +1,21 @@
+# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
+
+"""Tests for the functional test framework."""
+
+from pathlib import Path
+
+import pytest
+
+from pylint import testutils
+from pylint.testutils.functional import FunctionalTestFile
+
+HERE = Path(__file__).parent
+DATA_DIRECTORY = HERE / "data"
+
+
+def test_parsing_of_pylintrc_init_hook() -> None:
+ """Test that we correctly parse an init-hook in a settings file."""
+ with pytest.raises(RuntimeError):
+ test_file = FunctionalTestFile(str(DATA_DIRECTORY), "init_hook.py")
+ testutils.LintModuleTest(test_file)