Emit an error when entry points are duplicated

This avoids flake8 silently ignoring one of the plugins and
fixes https://gitlab.com/pycqa/flake8/-/issues/634.
This commit is contained in:
Peter Law 2020-05-08 13:10:26 +01:00
parent 03c7dd3a8d
commit acced5f62a
4 changed files with 52 additions and 0 deletions

View file

@ -1,9 +1,13 @@
"""Integration tests for plugin loading."""
import pytest
from flake8.main import application
from flake8 import exceptions
LOCAL_PLUGIN_CONFIG = 'tests/fixtures/config_files/local-plugin.ini'
LOCAL_PLUGIN_PATH_CONFIG = 'tests/fixtures/config_files/local-plugin-path.ini'
LOCAL_PLUGIN_DUPLICATE_CONFIG = 'tests/fixtures/config_files/local-plugin-duplicate-entry-point.ini'
class ExtensionTestPlugin(object):
@ -61,3 +65,10 @@ def test_enable_local_plugin_at_non_installed_path():
app.initialize(['flake8', '--config', LOCAL_PLUGIN_PATH_CONFIG])
assert app.check_plugins['XE'].plugin.name == 'ExtensionTestPlugin2'
def test_reject_local_plugins_with_duplicate_entry_point():
"""Reject duplicate entry points in local-plugins config section."""
with pytest.raises(exceptions.DuplicatePluginEntryPoint):
app = application.Application()
app.initialize(['flake8', '--config', LOCAL_PLUGIN_DUPLICATE_CONFIG])