|
1 | 1 | from __future__ import (absolute_import, division, print_function,
|
2 | 2 | unicode_literals)
|
3 | 3 |
|
4 |
| -import six |
5 |
| - |
6 | 4 | from fnmatch import fnmatch
|
7 | 5 | import os
|
8 |
| -import sys |
9 | 6 |
|
10 | 7 | from nose.tools import assert_equal
|
11 | 8 | from nose.plugins.skip import SkipTest
|
|
20 | 17 | import matplotlib
|
21 | 18 |
|
22 | 19 |
|
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 |
| - |
41 | 20 | PEP8_ADDITIONAL_IGNORE = ['E111',
|
42 | 21 | 'E112',
|
43 | 22 | 'E113',
|
|
53 | 32 | 'E131',
|
54 | 33 | 'E265']
|
55 | 34 |
|
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') |
146 | 37 |
|
147 | 38 |
|
148 | 39 | if HAS_PEP8:
|
149 | 40 | 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 = [] |
152 | 43 |
|
153 |
| - #: A class attribute to store the lines of failing tests. |
| 44 | + # A class attribute to store the lines of failing tests. |
154 | 45 | _global_deferred_print = []
|
155 | 46 |
|
156 |
| - #: A class attribute to store patterns which have seen exceptions. |
| 47 | + # A class attribute to store patterns which have seen exceptions. |
157 | 48 | matched_exclusions = set()
|
158 | 49 |
|
159 | 50 | def get_file_results(self):
|
@@ -191,11 +82,11 @@ def get_file_results(self):
|
191 | 82 | return self.file_errors
|
192 | 83 |
|
193 | 84 |
|
194 |
| -def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES, |
| 85 | +def assert_pep8_conformance(module=matplotlib, exclude_files=None, |
195 | 86 | extra_exclude_file=EXTRA_EXCLUDE_FILE,
|
196 |
| - extra_exclude_directories=None, |
197 | 87 | 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): |
199 | 90 | """
|
200 | 91 | Tests the matplotlib codebase against the "pep8" tool.
|
201 | 92 |
|
@@ -225,7 +116,8 @@ def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
|
225 | 116 | # Support for egg shared object wrappers, which are not PEP8 compliant,
|
226 | 117 | # nor part of the matplotlib repository.
|
227 | 118 | # 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) |
229 | 121 |
|
230 | 122 | # Allow users to add their own exclude list.
|
231 | 123 | 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,
|
260 | 152 |
|
261 | 153 |
|
262 | 154 | 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) |
264 | 265 |
|
265 | 266 |
|
266 | 267 | def test_pep8_conformance_examples():
|
|
0 commit comments