-
-
Notifications
You must be signed in to change notification settings - Fork 384
/
test_plugins.py
99 lines (84 loc) · 2.54 KB
/
test_plugins.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
"""
These test ensures that each plugin is enabled and working.
We only test a single warning from each plugin.
We do not test that any of the 3rd party plugins work correctly.
It is not our responsibility.
"""
import subprocess
PLUGINS = (
'B002', # flake8-bugbear
'C101', # flake8-coding
'A001', # flake8-builtins
'C400', # flake8-comprehensions
'C819', # flake8-commas
'D103', # flake8-docstring
'E225', # pycodestyle
'E800', # flake8-eradicate
'F401', # flake8
'I001', # flake8-isort
'N400', # flake8-broken-line
'N802', # pep8-naming
'P101', # flake8-string-format
'Q000', # flake8-quotes
'Q003', # flake8-quotes
'S001', # flake8-pep3101
'S101', # flake8-bandit
'T100', # flake8-debugger
'RST215', # flake8-rst-docstrings
'EXE003', # flake8-executable
'DAR101', # darglint
)
def _assert_plugin_output(output):
for plugin_code in PLUGINS:
assert output.count(plugin_code) > 0
def test_external_plugins(absolute_path):
"""End-to-End test to check that all plugins are enabled."""
filename = absolute_path('fixtures', 'external_plugins.py')
process = subprocess.Popen(
[
'flake8',
'--disable-noqa',
'--isolated',
'--enable-extensions',
'G',
filename,
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
encoding='utf8',
)
output, _ = process.communicate()
_assert_plugin_output(output)
def test_external_plugins_diff(absolute_path):
"""Ensures that our linter and all plugins work in ``diff`` mode."""
process = subprocess.Popen(
[
'diff',
'-uN', # is required to ignore missing files
'missing_file', # is required to transform file to diff
absolute_path('fixtures', 'external_plugins.py'),
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
encoding='utf8',
)
output = subprocess.check_output(
[
'flake8',
'--disable-noqa',
'--isolated',
'--enable-extensions',
'G',
'--diff', # is required to test diffs! ;)
'--exit-zero', # to allow failures
],
stdin=process.stdout,
stderr=subprocess.PIPE,
universal_newlines=True,
encoding='utf8',
)
process.communicate()
_assert_plugin_output(output)