mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
Add paths option in local-plugins config file.
This commit is contained in:
parent
8acf55e0f8
commit
423980164b
6 changed files with 84 additions and 6 deletions
5
tests/fixtures/config_files/local-plugin-path.ini
vendored
Normal file
5
tests/fixtures/config_files/local-plugin-path.ini
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[flake8:local-plugins]
|
||||
extension =
|
||||
XE = aplugin:ExtensionTestPlugin2
|
||||
paths =
|
||||
../../integration/subdir/
|
||||
16
tests/integration/subdir/aplugin.py
Normal file
16
tests/integration/subdir/aplugin.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"""Module that is off sys.path by default, for testing local-plugin-paths."""
|
||||
|
||||
|
||||
class ExtensionTestPlugin2(object):
|
||||
"""Extension test plugin in its own directory."""
|
||||
|
||||
name = 'ExtensionTestPlugin2'
|
||||
version = '1.0.0'
|
||||
|
||||
def __init__(self, tree):
|
||||
"""Construct an instance of test plugin."""
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
"""Do nothing."""
|
||||
pass
|
||||
|
|
@ -3,6 +3,7 @@ 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(object):
|
||||
|
|
@ -56,3 +57,11 @@ def test_local_plugin_can_add_option():
|
|||
['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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue