mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 21:16:54 +00:00
extend black formatting to tests as well
This commit is contained in:
parent
a7174759e9
commit
af1668bf04
45 changed files with 1644 additions and 1307 deletions
|
|
@ -1,15 +1,15 @@
|
|||
"""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'
|
||||
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'
|
||||
name = "ExtensionTestPlugin"
|
||||
version = "1.0.0"
|
||||
|
||||
def __init__(self, tree):
|
||||
"""Construct an instance of test plugin."""
|
||||
|
|
@ -20,14 +20,14 @@ class ExtensionTestPlugin:
|
|||
@classmethod
|
||||
def add_options(cls, parser):
|
||||
"""Register options."""
|
||||
parser.add_option('--anopt')
|
||||
parser.add_option("--anopt")
|
||||
|
||||
|
||||
class ReportTestPlugin:
|
||||
"""Report test plugin."""
|
||||
|
||||
name = 'ReportTestPlugin'
|
||||
version = '1.0.0'
|
||||
name = "ReportTestPlugin"
|
||||
version = "1.0.0"
|
||||
|
||||
def __init__(self, tree):
|
||||
"""Construct an instance of test plugin."""
|
||||
|
|
@ -39,28 +39,29 @@ class ReportTestPlugin:
|
|||
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])
|
||||
app.initialize(["flake8", "--config", LOCAL_PLUGIN_CONFIG])
|
||||
|
||||
assert app.check_plugins is not None
|
||||
assert app.check_plugins['XE'].plugin is ExtensionTestPlugin
|
||||
assert app.check_plugins["XE"].plugin is ExtensionTestPlugin
|
||||
assert app.formatting_plugins is not None
|
||||
assert app.formatting_plugins['XR'].plugin is ReportTestPlugin
|
||||
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'])
|
||||
["flake8", "--config", LOCAL_PLUGIN_CONFIG, "--anopt", "foo"]
|
||||
)
|
||||
|
||||
assert app.options is not None
|
||||
assert app.options.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])
|
||||
app.initialize(["flake8", "--config", LOCAL_PLUGIN_PATH_CONFIG])
|
||||
|
||||
assert app.check_plugins is not None
|
||||
assert app.check_plugins['XE'].plugin.name == 'ExtensionTestPlugin2'
|
||||
assert app.check_plugins["XE"].plugin.name == "ExtensionTestPlugin2"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue