Skip to content

Commit d65f921

Browse files
committed
refactor pep8 conformance test
1 parent ccb8efe commit d65f921

File tree

1 file changed

+121
-120
lines changed

1 file changed

+121
-120
lines changed

lib/matplotlib/tests/test_coding_standards.py

Lines changed: 121 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
5-
64
from fnmatch import fnmatch
75
import os
8-
import sys
96

107
from nose.tools import assert_equal
118
from nose.plugins.skip import SkipTest
@@ -20,24 +17,6 @@
2017
import matplotlib
2118

2219

23-
EXTRA_EXCLUDE_FILE = os.path.join(os.path.dirname(__file__),
24-
'.pep8_test_exclude.txt')
25-
EXCLUDE_FILES = ['_delaunay.py',
26-
'_image.py',
27-
'_tri.py',
28-
'_backend_agg.py',
29-
'_tkagg.py',
30-
'ft2font.py',
31-
'_cntr.py',
32-
'_png.py',
33-
'_path.py',
34-
'ttconv.py',
35-
'_gtkagg.py',
36-
'_backend_gdk.py',
37-
'pyparsing*',
38-
'_qhull.py',
39-
'_macosx.py']
40-
4120
PEP8_ADDITIONAL_IGNORE = ['E111',
4221
'E112',
4322
'E113',
@@ -53,107 +32,19 @@
5332
'E131',
5433
'E265']
5534

56-
EXPECTED_BAD_FILES = ['*/matplotlib/__init__.py',
57-
'*/matplotlib/_cm.py',
58-
'*/matplotlib/_mathtext_data.py',
59-
'*/matplotlib/_pylab_helpers.py',
60-
'*/matplotlib/afm.py',
61-
'*/matplotlib/artist.py',
62-
'*/matplotlib/axis.py',
63-
'*/matplotlib/backend_bases.py',
64-
'*/matplotlib/bezier.py',
65-
'*/matplotlib/cbook.py',
66-
'*/matplotlib/collections.py',
67-
'*/matplotlib/dviread.py',
68-
'*/matplotlib/font_manager.py',
69-
'*/matplotlib/fontconfig_pattern.py',
70-
'*/matplotlib/gridspec.py',
71-
'*/matplotlib/legend.py',
72-
'*/matplotlib/legend_handler.py',
73-
'*/matplotlib/mathtext.py',
74-
'*/matplotlib/mlab.py',
75-
'*/matplotlib/path.py',
76-
'*/matplotlib/patheffects.py',
77-
'*/matplotlib/pylab.py',
78-
'*/matplotlib/pyplot.py',
79-
'*/matplotlib/rcsetup.py',
80-
'*/matplotlib/stackplot.py',
81-
'*/matplotlib/texmanager.py',
82-
'*/matplotlib/transforms.py',
83-
'*/matplotlib/type1font.py',
84-
'*/matplotlib/widgets.py',
85-
'*/matplotlib/testing/decorators.py',
86-
'*/matplotlib/testing/image_util.py',
87-
'*/matplotlib/testing/noseclasses.py',
88-
'*/matplotlib/testing/jpl_units/Duration.py',
89-
'*/matplotlib/testing/jpl_units/Epoch.py',
90-
'*/matplotlib/testing/jpl_units/EpochConverter.py',
91-
'*/matplotlib/testing/jpl_units/StrConverter.py',
92-
'*/matplotlib/testing/jpl_units/UnitDbl.py',
93-
'*/matplotlib/testing/jpl_units/UnitDblConverter.py',
94-
'*/matplotlib/testing/jpl_units/UnitDblFormatter.py',
95-
'*/matplotlib/testing/jpl_units/__init__.py',
96-
'*/matplotlib/tri/triinterpolate.py',
97-
'*/matplotlib/tests/test_axes.py',
98-
'*/matplotlib/tests/test_bbox_tight.py',
99-
'*/matplotlib/tests/test_dates.py',
100-
'*/matplotlib/tests/test_delaunay.py',
101-
'*/matplotlib/tests/test_dviread.py',
102-
'*/matplotlib/tests/test_image.py',
103-
'*/matplotlib/tests/test_legend.py',
104-
'*/matplotlib/tests/test_lines.py',
105-
'*/matplotlib/tests/test_mathtext.py',
106-
'*/matplotlib/tests/test_rcparams.py',
107-
'*/matplotlib/tests/test_simplification.py',
108-
'*/matplotlib/tests/test_spines.py',
109-
'*/matplotlib/tests/test_streamplot.py',
110-
'*/matplotlib/tests/test_subplots.py',
111-
'*/matplotlib/tests/test_text.py',
112-
'*/matplotlib/tests/test_tightlayout.py',
113-
'*/matplotlib/tests/test_transforms.py',
114-
'*/matplotlib/tests/test_triangulation.py',
115-
'*/matplotlib/compat/subprocess.py',
116-
'*/matplotlib/backends/__init__.py',
117-
'*/matplotlib/backends/backend_agg.py',
118-
'*/matplotlib/backends/backend_cairo.py',
119-
'*/matplotlib/backends/backend_cocoaagg.py',
120-
'*/matplotlib/backends/backend_gdk.py',
121-
'*/matplotlib/backends/backend_gtk.py',
122-
'*/matplotlib/backends/backend_gtk3.py',
123-
'*/matplotlib/backends/backend_gtk3cairo.py',
124-
'*/matplotlib/backends/backend_gtkagg.py',
125-
'*/matplotlib/backends/backend_gtkcairo.py',
126-
'*/matplotlib/backends/backend_macosx.py',
127-
'*/matplotlib/backends/backend_mixed.py',
128-
'*/matplotlib/backends/backend_pgf.py',
129-
'*/matplotlib/backends/backend_ps.py',
130-
'*/matplotlib/backends/backend_svg.py',
131-
'*/matplotlib/backends/backend_template.py',
132-
'*/matplotlib/backends/backend_tkagg.py',
133-
'*/matplotlib/backends/backend_wx.py',
134-
'*/matplotlib/backends/backend_wxagg.py',
135-
'*/matplotlib/backends/tkagg.py',
136-
'*/matplotlib/backends/windowing.py',
137-
'*/matplotlib/backends/qt_editor/formlayout.py',
138-
'*/matplotlib/sphinxext/ipython_console_highlighting.py',
139-
'*/matplotlib/sphinxext/ipython_directive.py',
140-
'*/matplotlib/sphinxext/mathmpl.py',
141-
'*/matplotlib/sphinxext/only_directives.py',
142-
'*/matplotlib/sphinxext/plot_directive.py',
143-
'*/matplotlib/projections/__init__.py',
144-
'*/matplotlib/projections/geo.py',
145-
'*/matplotlib/projections/polar.py']
35+
EXTRA_EXCLUDE_FILE = os.path.join(os.path.dirname(__file__),
36+
'.pep8_test_exclude.txt')
14637

14738

14839
if HAS_PEP8:
14940
class StandardReportWithExclusions(pep8.StandardReport):
150-
#; A class attribute to store the exception exclusion file patterns.
151-
expected_bad_files = EXPECTED_BAD_FILES
41+
# A class attribute to store the exception exclusion file patterns.
42+
expected_bad_files = []
15243

153-
#: A class attribute to store the lines of failing tests.
44+
# A class attribute to store the lines of failing tests.
15445
_global_deferred_print = []
15546

156-
#: A class attribute to store patterns which have seen exceptions.
47+
# A class attribute to store patterns which have seen exceptions.
15748
matched_exclusions = set()
15849

15950
def get_file_results(self):
@@ -191,11 +82,11 @@ def get_file_results(self):
19182
return self.file_errors
19283

19384

194-
def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
85+
def assert_pep8_conformance(module=matplotlib, exclude_files=None,
19586
extra_exclude_file=EXTRA_EXCLUDE_FILE,
196-
extra_exclude_directories=None,
19787
pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE,
198-
dirname=None, expected_bad_files=None):
88+
dirname=None, expected_bad_files=None,
89+
extra_exclude_directories=None):
19990
"""
20091
Tests the matplotlib codebase against the "pep8" tool.
20192
@@ -225,7 +116,8 @@ def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
225116
# Support for egg shared object wrappers, which are not PEP8 compliant,
226117
# nor part of the matplotlib repository.
227118
# DO NOT ADD FILES *IN* THE REPOSITORY TO THIS LIST.
228-
pep8style.options.exclude.extend(exclude_files)
119+
if exclude_files is not None:
120+
pep8style.options.exclude.extend(exclude_files)
229121

230122
# Allow users to add their own exclude list.
231123
if extra_exclude_file is not None and os.path.exists(extra_exclude_file):
@@ -260,7 +152,116 @@ def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
260152

261153

262154
def test_pep8_conformance():
263-
assert_pep8_conformance()
155+
exclude_files = ['_delaunay.py',
156+
'_image.py',
157+
'_tri.py',
158+
'_backend_agg.py',
159+
'_tkagg.py',
160+
'ft2font.py',
161+
'_cntr.py',
162+
'_png.py',
163+
'_path.py',
164+
'ttconv.py',
165+
'_gtkagg.py',
166+
'_backend_gdk.py',
167+
'pyparsing*',
168+
'_qhull.py',
169+
'_macosx.py']
170+
171+
expected_bad_files = ['__init__.py',
172+
'_cm.py',
173+
'_mathtext_data.py',
174+
'_pylab_helpers.py',
175+
'afm.py',
176+
'artist.py',
177+
'axis.py',
178+
'backend_bases.py',
179+
'bezier.py',
180+
'cbook.py',
181+
'collections.py',
182+
'dviread.py',
183+
'font_manager.py',
184+
'fontconfig_pattern.py',
185+
'gridspec.py',
186+
'legend.py',
187+
'legend_handler.py',
188+
'mathtext.py',
189+
'mlab.py',
190+
'path.py',
191+
'patheffects.py',
192+
'pylab.py',
193+
'pyplot.py',
194+
'rcsetup.py',
195+
'stackplot.py',
196+
'texmanager.py',
197+
'transforms.py',
198+
'type1font.py',
199+
'widgets.py',
200+
'testing/decorators.py',
201+
'testing/image_util.py',
202+
'testing/noseclasses.py',
203+
'testing/jpl_units/Duration.py',
204+
'testing/jpl_units/Epoch.py',
205+
'testing/jpl_units/EpochConverter.py',
206+
'testing/jpl_units/StrConverter.py',
207+
'testing/jpl_units/UnitDbl.py',
208+
'testing/jpl_units/UnitDblConverter.py',
209+
'testing/jpl_units/UnitDblFormatter.py',
210+
'testing/jpl_units/__init__.py',
211+
'tri/triinterpolate.py',
212+
'tests/test_axes.py',
213+
'tests/test_bbox_tight.py',
214+
'tests/test_dates.py',
215+
'tests/test_delaunay.py',
216+
'tests/test_dviread.py',
217+
'tests/test_image.py',
218+
'tests/test_legend.py',
219+
'tests/test_lines.py',
220+
'tests/test_mathtext.py',
221+
'tests/test_rcparams.py',
222+
'tests/test_simplification.py',
223+
'tests/test_spines.py',
224+
'tests/test_streamplot.py',
225+
'tests/test_subplots.py',
226+
'tests/test_text.py',
227+
'tests/test_tightlayout.py',
228+
'tests/test_transforms.py',
229+
'tests/test_triangulation.py',
230+
'compat/subprocess.py',
231+
'backends/__init__.py',
232+
'backends/backend_agg.py',
233+
'backends/backend_cairo.py',
234+
'backends/backend_cocoaagg.py',
235+
'backends/backend_gdk.py',
236+
'backends/backend_gtk.py',
237+
'backends/backend_gtk3.py',
238+
'backends/backend_gtk3cairo.py',
239+
'backends/backend_gtkagg.py',
240+
'backends/backend_gtkcairo.py',
241+
'backends/backend_macosx.py',
242+
'backends/backend_mixed.py',
243+
'backends/backend_pgf.py',
244+
'backends/backend_ps.py',
245+
'backends/backend_svg.py',
246+
'backends/backend_template.py',
247+
'backends/backend_tkagg.py',
248+
'backends/backend_wx.py',
249+
'backends/backend_wxagg.py',
250+
'backends/tkagg.py',
251+
'backends/windowing.py',
252+
'backends/qt_editor/formlayout.py',
253+
'sphinxext/ipython_console_highlighting.py',
254+
'sphinxext/ipython_directive.py',
255+
'sphinxext/mathmpl.py',
256+
'sphinxext/only_directives.py',
257+
'sphinxext/plot_directive.py',
258+
'projections/__init__.py',
259+
'projections/geo.py',
260+
'projections/polar.py']
261+
expected_bad_files = ['*/matplotlib/' + s for s in expected_bad_files]
262+
assert_pep8_conformance(module=matplotlib,
263+
exclude_files=exclude_files,
264+
expected_bad_files=expected_bad_files)
264265

265266

266267
def test_pep8_conformance_examples():

0 commit comments

Comments
 (0)