Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Pep8ify examples #3425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Sep 9, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test the pep8 conformance of the mpl examples
  • Loading branch information
twmr committed Aug 28, 2014
commit 4a0f5f41aaa8b71bd030a00a030e550f47f133a3
1 change: 1 addition & 0 deletions 1 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ script:
# Generate the font caches in a single process before starting the
# multiple processes
- python -c "from matplotlib import font_manager"
- if [[ $BUILD_DOCS == false ]]; then export MPL_REPO_DIR=$PWD; fi # pep8-conformance test of the examples
- if [[ $BUILD_DOCS == false ]]; then mkdir ../tmp_test_dir; fi
- if [[ $BUILD_DOCS == false ]]; then cd ../tmp_test_dir; fi
- if [[ $BUILD_DOCS == false ]]; then python ../matplotlib/tests.py -sv --processes=8 --process-timeout=300 $TEST_ARGS; fi
Expand Down
39 changes: 37 additions & 2 deletions 39 lib/matplotlib/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ def get_file_results(self):

def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
extra_exclude_file=EXTRA_EXCLUDE_FILE,
pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE):
extra_exclude_directories=None,
pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE,
dirname=None):
"""
Tests the matplotlib codebase against the "pep8" tool.

Expand Down Expand Up @@ -228,7 +230,12 @@ def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
extra_exclude = [line.strip() for line in fh if line.strip()]
pep8style.options.exclude.extend(extra_exclude)

result = pep8style.check_files([os.path.dirname(module.__file__)])
if extra_exclude_directories:
pep8style.options.exclude.extend(extra_exclude_directories)

if dirname is None:
dirname = os.path.dirname(module.__file__)
result = pep8style.check_files([dirname])
if reporter is StandardReportWithExclusions:
msg = ("Found code syntax errors (and warnings):\n"
"{0}".format('\n'.join(reporter._global_deferred_print)))
Expand All @@ -253,6 +260,34 @@ def test_pep8_conformance():
assert_pep8_conformance()


def test_pep8_conformance_examples():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you re-factor the other test this way as well?

mpldirdefault = os.path.join(os.getcwd(), '..', '..', '..')
mpldir = os.environ.get('MPL_REPO_DIR', mpldirdefault)
exdir = os.path.join(mpldir, 'examples')
blacklist = ['color',
'event_handling',
'images_contours_and_fields',
'lines_bars_and_markers',
'misc',
'mplot3d',
'pie_and_polar_charts',
'pylab_examples',
'shapes_and_collections',
'showcase',
'specialty_plots',
'statistics',
'style_sheets',
'subplots_axes_and_figures',
'tests',
'text_labels_and_annotations',
'ticks_and_spines',
'units',
'user_interfaces',
'widgets']
assert_pep8_conformance(dirname=exdir,
extra_exclude_directories=blacklist)


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.