@@ -193,7 +193,9 @@ def get_file_results(self):
193
193
194
194
def assert_pep8_conformance (module = matplotlib , exclude_files = EXCLUDE_FILES ,
195
195
extra_exclude_file = EXTRA_EXCLUDE_FILE ,
196
- pep8_additional_ignore = PEP8_ADDITIONAL_IGNORE ):
196
+ extra_exclude_directories = None ,
197
+ pep8_additional_ignore = PEP8_ADDITIONAL_IGNORE ,
198
+ dirname = None ):
197
199
"""
198
200
Tests the matplotlib codebase against the "pep8" tool.
199
201
@@ -228,7 +230,12 @@ def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
228
230
extra_exclude = [line .strip () for line in fh if line .strip ()]
229
231
pep8style .options .exclude .extend (extra_exclude )
230
232
231
- result = pep8style .check_files ([os .path .dirname (module .__file__ )])
233
+ if extra_exclude_directories :
234
+ pep8style .options .exclude .extend (extra_exclude_directories )
235
+
236
+ if dirname is None :
237
+ dirname = os .path .dirname (module .__file__ )
238
+ result = pep8style .check_files ([dirname ])
232
239
if reporter is StandardReportWithExclusions :
233
240
msg = ("Found code syntax errors (and warnings):\n "
234
241
"{0}" .format ('\n ' .join (reporter ._global_deferred_print )))
@@ -253,6 +260,32 @@ def test_pep8_conformance():
253
260
assert_pep8_conformance ()
254
261
255
262
263
+ def test_pep8_conformance_examples ():
264
+ exdir = os .path .join (os .getcwd (), '..' , '..' , '..' , 'examples' )
265
+ blacklist = ['color' ,
266
+ 'event_handling' ,
267
+ 'images_contours_and_fields' ,
268
+ 'lines_bars_and_markers' ,
269
+ 'misc' ,
270
+ 'mplot3d' ,
271
+ 'pie_and_polar_charts' ,
272
+ 'pylab_examples' ,
273
+ 'shapes_and_collections' ,
274
+ 'showcase' ,
275
+ 'specialty_plots' ,
276
+ 'statistics' ,
277
+ 'style_sheets' ,
278
+ 'subplots_axes_and_figures' ,
279
+ 'tests' ,
280
+ 'text_labels_and_annotations' ,
281
+ 'ticks_and_spines' ,
282
+ 'units' ,
283
+ 'user_interfaces' ,
284
+ 'widgets' ]
285
+ assert_pep8_conformance (dirname = exdir ,
286
+ extra_exclude_directories = blacklist )
287
+
288
+
256
289
if __name__ == '__main__' :
257
290
import nose
258
291
nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments