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
|
from __future__ import annotations
import importlib.metadata
from unittest import mock
from flake8.main import debug
from flake8.plugins import finder
def test_debug_information():
def _plugin(pkg, version, ep_name):
return finder.LoadedPlugin(
finder.Plugin(
pkg,
version,
importlib.metadata.EntryPoint(
ep_name, "dne:dne", "flake8.extension"
),
),
None,
{},
)
plugins = finder.Plugins(
checkers=finder.Checkers(
tree=[
_plugin("pkg1", "1.2.3", "X1"),
_plugin("pkg1", "1.2.3", "X2"),
_plugin("pkg2", "4.5.6", "X3"),
],
logical_line=[],
physical_line=[],
),
reporters={},
disabled=[],
)
info = debug.information("9001", plugins)
assert info == {
"version": "9001",
"plugins": [
{"plugin": "pkg1", "version": "1.2.3"},
{"plugin": "pkg2", "version": "4.5.6"},
],
"platform": {
"python_implementation": mock.ANY,
"python_version": mock.ANY,
"system": mock.ANY,
},
}
|