|
14 | 14 | from concurrent.futures import ProcessPoolExecutor
|
15 | 15 | from concurrent.futures.process import BrokenProcessPool
|
16 | 16 | from pickle import PickleError
|
| 17 | +from typing import TYPE_CHECKING |
| 18 | +from unittest.mock import patch |
17 | 19 |
|
18 | 20 | import dill
|
19 | 21 | import pytest
|
20 |
| -from astroid import nodes |
21 | 22 |
|
22 | 23 | import pylint.interfaces
|
23 | 24 | import pylint.lint.parallel
|
|
30 | 31 | from pylint.typing import FileItem
|
31 | 32 | from pylint.utils import LinterStats, ModuleStats
|
32 | 33 |
|
| 34 | +if TYPE_CHECKING: |
| 35 | + from astroid import nodes |
| 36 | + |
33 | 37 |
|
34 | 38 | def _gen_file_data(idx: int = 0) -> FileItem:
|
35 | 39 | """Generates a file to use as a stream."""
|
@@ -182,6 +186,17 @@ def test_worker_initialize_with_package_paths(self) -> None:
|
182 | 186 | )
|
183 | 187 | assert "fake-path" in sys.path
|
184 | 188 |
|
| 189 | + def test_worker_initialize_reregisters_custom_plugins(self) -> None: |
| 190 | + linter = PyLinter(reporter=Reporter()) |
| 191 | + linter.load_plugin_modules(["pylint.extensions.private_import"]) |
| 192 | + |
| 193 | + pickled = dill.dumps(linter) |
| 194 | + with patch( |
| 195 | + "pylint.extensions.private_import.register", side_effect=AssertionError |
| 196 | + ): |
| 197 | + with pytest.raises(AssertionError): |
| 198 | + worker_initialize(linter=pickled) |
| 199 | + |
185 | 200 | @pytest.mark.needs_two_cores
|
186 | 201 | def test_worker_initialize_pickling(self) -> None:
|
187 | 202 | """Test that we can pickle objects that standard pickling in multiprocessing can't.
|
|
0 commit comments