mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
Refactor off-by-default plugins and enabling them
We move the logic to add or remove a plugin from the default ignore list to individual methods on the Plugin class (Plugin#enable, Plugin#disable) and use that when registering and parsing options. If the plugin is off-by-default, Plugin#register_options will use Plugin#disable. When parsing options via Plugin#provide_options, if the plugin has been specified in --enable-extensions then it will be re-enabled via Plugin#enable.
This commit is contained in:
parent
50d74e3cce
commit
91e07ebcff
4 changed files with 34 additions and 5 deletions
|
|
@ -1,4 +1,6 @@
|
|||
"""Tests for flake8.plugins.manager.Plugin."""
|
||||
import optparse
|
||||
|
||||
from flake8 import exceptions
|
||||
from flake8.plugins import manager
|
||||
|
||||
|
|
@ -138,14 +140,15 @@ def test_provide_options():
|
|||
entry_point = mock.Mock(spec=['require', 'resolve', 'load'])
|
||||
plugin_obj = mock.Mock(spec_set=['name', 'version', 'add_options',
|
||||
'parse_options'])
|
||||
option_values = optparse.Values({'enable_extensions': []})
|
||||
option_manager = mock.Mock()
|
||||
plugin = manager.Plugin('T000', entry_point)
|
||||
plugin._plugin = plugin_obj
|
||||
|
||||
# Call the method we're testing.
|
||||
plugin.provide_options(option_manager, 'options', None)
|
||||
plugin.provide_options(option_manager, option_values, None)
|
||||
|
||||
# Assert that we call add_options
|
||||
plugin_obj.parse_options.assert_called_once_with(
|
||||
option_manager, 'options', None
|
||||
option_manager, option_values, None
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue