Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Convert a few test files to Pytest #7318

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 4 commits into from
Oct 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 0 additions & 5 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,10 +1470,8 @@ def _jupyter_nbextension_paths():

default_test_modules = [
'matplotlib.tests.test_agg',
'matplotlib.tests.test_animation',
'matplotlib.tests.test_arrow_patches',
'matplotlib.tests.test_artist',
'matplotlib.tests.test_axes',
'matplotlib.tests.test_backend_bases',
'matplotlib.tests.test_backend_pdf',
'matplotlib.tests.test_backend_pgf',
Expand All @@ -1483,7 +1481,6 @@ def _jupyter_nbextension_paths():
'matplotlib.tests.test_backend_svg',
'matplotlib.tests.test_basic',
'matplotlib.tests.test_bbox_tight',
'matplotlib.tests.test_cbook',
'matplotlib.tests.test_coding_standards',
'matplotlib.tests.test_collections',
'matplotlib.tests.test_colorbar',
Expand All @@ -1508,7 +1505,6 @@ def _jupyter_nbextension_paths():
'matplotlib.tests.test_pickle',
'matplotlib.tests.test_png',
'matplotlib.tests.test_quiver',
'matplotlib.tests.test_rcparams',
'matplotlib.tests.test_sankey',
'matplotlib.tests.test_scale',
'matplotlib.tests.test_simplification',
Expand All @@ -1520,7 +1516,6 @@ def _jupyter_nbextension_paths():
'matplotlib.tests.test_table',
'matplotlib.tests.test_text',
'matplotlib.tests.test_texmanager',
'matplotlib.tests.test_ticker',
'matplotlib.tests.test_tightlayout',
'matplotlib.tests.test_transforms',
'matplotlib.tests.test_triangulation',
Expand Down
64 changes: 31 additions & 33 deletions lib/matplotlib/tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import os
import sys
import tempfile

import numpy as np
from numpy.testing import assert_equal
from nose.tools import assert_false, assert_true
import pytest

import matplotlib as mpl
from matplotlib import pyplot as plt
from matplotlib import animation
Expand Down Expand Up @@ -67,12 +68,12 @@ def animate(i):
anim.save(filename, dpi=dpi, writer=writer,
savefig_kwargs=savefig_kwargs)

assert_equal(writer.fig, fig)
assert_equal(writer.outfile, filename)
assert_equal(writer.dpi, dpi)
assert_equal(writer.args, ())
assert_equal(writer.savefig_kwargs, savefig_kwargs)
assert_equal(writer._count, num_frames)
assert writer.fig == fig
assert writer.outfile == filename
assert writer.dpi == dpi
assert writer.args == ()
assert writer.savefig_kwargs == savefig_kwargs
assert writer._count == num_frames


@animation.writers.register('null')
Expand All @@ -93,23 +94,25 @@ def isAvailable(self):
return True


WRITER_OUTPUT = dict(ffmpeg='mp4', ffmpeg_file='mp4',
mencoder='mp4', mencoder_file='mp4',
avconv='mp4', avconv_file='mp4',
imagemagick='gif', imagemagick_file='gif',
null='null')
WRITER_OUTPUT = [
('ffmpeg', 'mp4'),
('ffmpeg_file', 'mp4'),
('mencoder', 'mp4'),
('mencoder_file', 'mp4'),
('avconv', 'mp4'),
('avconv_file', 'mp4'),
('imagemagick', 'gif'),
('imagemagick_file', 'gif'),
('null', 'null')
]


# Smoke test for saving animations. In the future, we should probably
# design more sophisticated tests which compare resulting frames a-la
# matplotlib.testing.image_comparison
def test_save_animation_smoketest():
for writer, extension in six.iteritems(WRITER_OUTPUT):
yield check_save_animation, writer, extension


@cleanup
def check_save_animation(writer, extension='mp4'):
@pytest.mark.parametrize('writer, extension', WRITER_OUTPUT)
def test_save_animation_smoketest(writer, extension):
try:
# for ImageMagick the rcparams must be patched to account for
# 'convert' being a built in MS tool, not the imagemagick
Expand Down Expand Up @@ -174,26 +177,21 @@ def test_movie_writer_registry():
ffmpeg_path = mpl.rcParams['animation.ffmpeg_path']
# Not sure about the first state as there could be some writer
# which set rcparams
#assert_false(animation.writers._dirty)
assert_true(len(animation.writers._registered) > 0)
# assert not animation.writers._dirty
assert len(animation.writers._registered) > 0
animation.writers.list() # resets dirty state
assert_false(animation.writers._dirty)
assert not animation.writers._dirty
mpl.rcParams['animation.ffmpeg_path'] = u"not_available_ever_xxxx"
assert_true(animation.writers._dirty)
assert animation.writers._dirty
animation.writers.list() # resets
assert_false(animation.writers._dirty)
assert_false(animation.writers.is_available("ffmpeg"))
assert not animation.writers._dirty
assert not animation.writers.is_available("ffmpeg")
# something which is guaranteed to be available in path
# and exits immediately
bin = u"true" if sys.platform != 'win32' else u"where"
mpl.rcParams['animation.ffmpeg_path'] = bin
assert_true(animation.writers._dirty)
assert animation.writers._dirty
animation.writers.list() # resets
assert_false(animation.writers._dirty)
assert_true(animation.writers.is_available("ffmpeg"))
assert not animation.writers._dirty
assert animation.writers.is_available("ffmpeg")
mpl.rcParams['animation.ffmpeg_path'] = ffmpeg_path


if __name__ == "__main__":
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
Loading