summaryrefslogtreecommitdiff
path: root/tests/test_check_parallel.py
diff options
context:
space:
mode:
authorDrummond Ogilvie <drum.ogilvie@ovo.com>2022-10-20 10:16:34 +0100
committerGitHub <noreply@github.com>2022-10-20 11:16:34 +0200
commit015f3403385896f70ba946e10ad8354f1a59a967 (patch)
tree2c84d9c90f3911fca7da69cb4269a60478cbb2cc /tests/test_check_parallel.py
parente8ba3eb002b533e6640d6eeb25a66bab04602951 (diff)
downloadpylint-git-015f3403385896f70ba946e10ad8354f1a59a967.tar.gz
Swap plugin cache to pickle-able values when done (#7640)
When the dictionary has served its purpose (making plugin loading pre-and-post init a consistent behaviour), we swap it for bools indicating whether or not a module was loaded. We don't currently use the bools, but it seemed a sensible choice. The main idea is to make the dictionary fully pickle-able, so that when dill pickles the linter for multiprocessing, it doesn't crash horribly. Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Diffstat (limited to 'tests/test_check_parallel.py')
-rw-r--r--tests/test_check_parallel.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_check_parallel.py b/tests/test_check_parallel.py
index 0c872ff8d..420ed3d93 100644
--- a/tests/test_check_parallel.py
+++ b/tests/test_check_parallel.py
@@ -11,6 +11,7 @@ from __future__ import annotations
import argparse
import multiprocessing
import os
+from pickle import PickleError
import dill
import pytest
@@ -231,6 +232,24 @@ class TestCheckParallelFramework:
assert stats.statement == 18
assert stats.warning == 0
+ def test_linter_with_unpickleable_plugins_is_pickleable(self) -> None:
+ """The linter needs to be pickle-able in order to be passed between workers"""
+ linter = PyLinter(reporter=Reporter())
+ # We load an extension that we know is not pickle-safe
+ linter.load_plugin_modules(["pylint.extensions.overlapping_exceptions"])
+ try:
+ dill.dumps(linter)
+ assert False, "Plugins loaded were pickle-safe! This test needs altering"
+ except (KeyError, TypeError, PickleError, NotImplementedError):
+ pass
+
+ # And expect this call to make it pickle-able
+ linter.load_plugin_configuration()
+ try:
+ dill.dumps(linter)
+ except KeyError:
+ assert False, "Cannot pickle linter when using non-pickleable plugin"
+
def test_worker_check_sequential_checker(self) -> None:
"""Same as test_worker_check_single_file_no_checkers with SequentialTestChecker."""
linter = PyLinter(reporter=Reporter())