summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-07-27 08:15:56 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-08-03 16:48:39 -0500
commite14d0e6352efcf78d33c896a425ddc41405acd02 (patch)
tree1993ee784eaf52b1d64bd64fb5c786b7f412f060 /tests
parent7e806824dfb6934228880585a7caf3c7a81aafc9 (diff)
downloadflake8-e14d0e6352efcf78d33c896a425ddc41405acd02.tar.gz
Serialize Checkers PluginTypeManager to a dict
It seems likely that the multiprocessing module on Windows is not capable of serializing an object with the structure that we have and preserving the attributes we dynamically set on plugins (like the FlakesChecker). To avoid issues like this with all plugins (although we have only found this on Windows with the FlakesChecker), let's try serializing the Checkers PluginTypeManager to a dictionary so that the only object that a Queue is really trying to serialize/deserialize is the FlakesChecker itself. Related to #179
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/test_checker.py6
-rw-r--r--tests/unit/test_checker_manager.py8
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/integration/test_checker.py b/tests/integration/test_checker.py
index 5c013b6..1b8a3c5 100644
--- a/tests/integration/test_checker.py
+++ b/tests/integration/test_checker.py
@@ -63,7 +63,11 @@ def test_handle_file_plugins(plugin_target):
# Prevent it from reading lines from stdin or somewhere else
with mock.patch('flake8.processor.FileProcessor.read_lines',
return_value=['Line 1']):
- file_checker = checker.FileChecker('-', checks, mock.MagicMock())
+ file_checker = checker.FileChecker(
+ '-',
+ checks.to_dictionary(),
+ mock.MagicMock()
+ )
# Do not actually build an AST
file_checker.processor.build_ast = lambda: True
diff --git a/tests/unit/test_checker_manager.py b/tests/unit/test_checker_manager.py
index 7e9c5b1..e5562ef 100644
--- a/tests/unit/test_checker_manager.py
+++ b/tests/unit/test_checker_manager.py
@@ -47,8 +47,14 @@ def test_make_checkers():
"""Verify that we create a list of FileChecker instances."""
style_guide = style_guide_mock()
files = ['file1', 'file2']
+ checkplugins = mock.Mock()
+ checkplugins.to_dictionary.return_value = {
+ 'ast_plugins': [],
+ 'logical_line_plugins': [],
+ 'physical_line_plugins': [],
+ }
with mock.patch('flake8.checker.multiprocessing', None):
- manager = checker.Manager(style_guide, files, [])
+ manager = checker.Manager(style_guide, files, checkplugins)
with mock.patch('flake8.utils.filenames_from') as filenames_from:
filenames_from.side_effect = [['file1'], ['file2']]