astropy / package-template

Template for packages that use Astropy. Maintainer: @astrofrog
http://docs.astropy.org/projects/package-template/en/latest/
Other
60 stars 63 forks source link

tox displays plot during testing #450

Closed bmorris3 closed 4 years ago

bmorris3 commented 4 years ago

I'm using the package template over here and running into a small problem when running tox -e test locally. When tox gets to the step:

test run-test: commands[1] | pytest --pyargs eugene /Users/brettmorris/git/eugene/docs

(i.e. test the docs), it actually displays one of the plots to the screen generated by the plot directive in the documentation. How can we suppress plots from being displayed to screen during local testing? Thanks!

bmorris3 commented 4 years ago

Upon further investigation it wasn't the plot directive, it was the code-block that executed the plot that was causing the problem. If I add

...
[testenv]
setenv = MPLBACKEND=agg
...

to my tox.ini I can run the tests locally without getting a plot.

astrofrog commented 4 years ago

That is indeed the best way to solve that issue. Should we include it by default in the template?

bmorris3 commented 4 years ago

My vote is yes! See #453.