Closed bmorris3 closed 8 years ago
This is not an astroplan
-specific issue.
The tests for other Astropy-affiliated packages fail or even crash if DISPLAY
isn't configured correctly and a matplotlib plot is made.
The solution is to set DISPLAY e.g. like this https://github.com/astrofrog/wcsaxes/blob/master/.travis.yml#L75
# Make sure that interactive matplotlib backends work
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
# Make sure matplotlib uses PyQT not PySide
- export QT_API=pyqt
Maybe @mdboom or @astrofrog can comment if there is something in the Astropy test runner that can automatically handle this? Or maybe this is just something that should be documented for users / contributors, e.g. here? http://astropy.readthedocs.org/en/latest/known_issues.html#build-installation-test-issues
The fix @cdeil points out is the correct one. The issue is that really matplotlib should default to non-interactive Agg, but not quite sure why it doesn't when we run tests.
@astrofrog I just thought of something ... can't we just add
import matplotlib
matplotlib.use('agg')
in the pytest setup (e.g. here: https://github.com/astropy/astroplan/blob/master/astroplan/conftest.py#L34) so that matplotlib tests for all users run with a non-interactive matplotlib backend? No more fiddling with DISPLAY or pop-up windows when running the tests.
@cdeil - I tried that before, but had issues with it related to the fact pytest imports the module before running its setup. In other words, astroplan
has to be imported before conftest.py
is. If importing astroplan
causes matplotlib
to be imported, then it won't work. But otherwise it's worth the try.
No longer an issue, and as @cdeil points out, probably not an astroplan issue.
...
Any ideas @cdeil @jberlanga @eteq?