summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-02-23 23:20:34 -0600
committerIan Cordasco <graffatcolmingov@gmail.com>2016-02-23 23:20:34 -0600
commit24d2689a0519cb453eb67d6a0ef37f60efc8f0fd (patch)
tree6b1d8c0c83fe58455744e82e985dd62dc9e88873 /tests
parent1cd5fea73066f96753bbc69cbbfa7f96e8d50e4a (diff)
downloadflake8-24d2689a0519cb453eb67d6a0ef37f60efc8f0fd.tar.gz
Distinguish check types via plugin type manager
Flake8 and pep8 has historically supported three types of checks: - Plugins that accept the physical line - Plugins that accept the logical line - Plugins that accept the AST tree The logical place to make this distinction is on the Checkers plugin type manager class. This adds the foundation for finding plugins that fall into each class.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index 34b4909..615f327 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -4,6 +4,7 @@ import mock
import pytest
+from flake8.plugins import manager as plugin_manager
from flake8 import utils
@@ -86,3 +87,24 @@ def test_filenames_from_a_single_file():
assert len(filenames) == 1
assert ['flake8/__init__.py'] == filenames
+
+
+def test_parameters_for_class_plugin():
+ """Verify that we can retrieve the parameters for a class plugin."""
+ class FakeCheck(object):
+ def __init__(self, tree):
+ pass
+
+ plugin = plugin_manager.Plugin('plugin-name', object())
+ plugin._plugin = FakeCheck
+ assert utils.parameters_for(plugin) == ['tree']
+
+
+def test_parameters_for_function_plugin():
+ """Verify that we retrieve the parameters for a function plugin."""
+ def fake_plugin(physical_line, self, tree):
+ pass
+
+ plugin = plugin_manager.Plugin('plugin-name', object())
+ plugin._plugin = fake_plugin
+ assert utils.parameters_for(plugin) == ['physical_line', 'self', 'tree']