blob: 1b6203e1eb788ad9ba58628aa31153ee109489d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
"""Integration tests for plugin loading."""
from flake8.main import application
LOCAL_PLUGIN_CONFIG = 'tests/fixtures/config_files/local-plugin.ini'
LOCAL_PLUGIN_PATH_CONFIG = 'tests/fixtures/config_files/local-plugin-path.ini'
class ExtensionTestPlugin:
"""Extension test plugin."""
name = 'ExtensionTestPlugin'
version = '1.0.0'
def __init__(self, tree):
"""Construct an instance of test plugin."""
def run(self):
"""Do nothing."""
@classmethod
def add_options(cls, parser):
"""Register options."""
parser.add_option('--anopt')
class ReportTestPlugin:
"""Report test plugin."""
name = 'ReportTestPlugin'
version = '1.0.0'
def __init__(self, tree):
"""Construct an instance of test plugin."""
def run(self):
"""Do nothing."""
def test_enable_local_plugin_from_config():
"""App can load a local plugin from config file."""
app = application.Application()
app.initialize(['flake8', '--config', LOCAL_PLUGIN_CONFIG])
assert app.check_plugins['XE'].plugin is ExtensionTestPlugin
assert app.formatting_plugins['XR'].plugin is ReportTestPlugin
def test_local_plugin_can_add_option():
"""A local plugin can add a CLI option."""
app = application.Application()
app.initialize(
['flake8', '--config', LOCAL_PLUGIN_CONFIG, '--anopt', 'foo'])
assert app.options.anopt == 'foo'
def test_enable_local_plugin_at_non_installed_path():
"""Can add a paths option in local-plugins config section for finding."""
app = application.Application()
app.initialize(['flake8', '--config', LOCAL_PLUGIN_PATH_CONFIG])
assert app.check_plugins['XE'].plugin.name == 'ExtensionTestPlugin2'
|