Skip to content

Conversation

@DPeterK
Copy link
Member

@DPeterK DPeterK commented Apr 29, 2014

This PR allows the Iris test suite to successfully run in an environment where matplotlib is not available. This is achieved by adding a new test decorator (skip_plot) that when used to decorate a test class or function means it will be skipped if matplotlib cannot be imported.

To avoid import errors in test modules that use matplotlib (or Iris plotting modules), importing of these modules is wrapped up in a try clause.

@bjlittle bjlittle self-assigned this May 6, 2014
Copy link
Member

Choose a reason for hiding this comment

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

@dkillick To tie the _MPL_AVAILABLE even tighter to your try-except block, you could put it in a try-except-else block i.e.

try:
    import matplotlib
    ...
except ImportError:
    _MPL_AVAILABLE = False
else:
    _MPL_AVAILABLE = True

Just a suggestion, your call ...

@DPeterK
Copy link
Member Author

DPeterK commented May 6, 2014

Turns out I hadn't rebased since #1113 was merged - now done so the Travis build should complete.

I've also changed the try-except statements around the matplotlib imports in test scripts to instead use if tests.MPL_AVAILABLE.

Copy link
Member

Choose a reason for hiding this comment

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

@dkillick Has this not changed to if tests.MPL_AVAILABLE for a reason ... ?

@DPeterK
Copy link
Member Author

DPeterK commented May 6, 2014

Made the changes as above for the four test modules accidentally missed the first time around...

@bjlittle
Copy link
Member

bjlittle commented May 6, 2014

Excellent, thanks @dkillick 👍 ... could you squash your commit history, then I'll merge.

@DPeterK
Copy link
Member Author

DPeterK commented May 6, 2014

Squashed.

bjlittle added a commit that referenced this pull request May 6, 2014
Make matplotlib an optional Iris tests dependency
@bjlittle bjlittle merged commit 037a2da into SciTools:master May 6, 2014
@ajdawson ajdawson mentioned this pull request May 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants