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

Skip to content

TST : add time out to ani.save #2776

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

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 18 additions & 2 deletions lib/matplotlib/tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
unicode_literals)

import six

import sys
import tempfile

import signal
import numpy as np
from nose import with_setup
from matplotlib import pyplot as plt
Expand All @@ -20,6 +20,14 @@
imagemagick='gif', imagemagick_file='gif')


class TimeoutException(Exception):
pass


def _timeout_handler(signum, frame):
raise TimeoutException()


# 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
Expand Down Expand Up @@ -51,12 +59,20 @@ def animate(i):
# Use NamedTemporaryFile: will be automatically deleted
F = tempfile.NamedTemporaryFile(suffix='.' + extension)
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=5)

old_handler = signal.signal(signal.SIGALRM, _timeout_handler)

try:
signal.alarm(100)
anim.save(F.name, fps=30, writer=writer)
except UnicodeDecodeError:
raise KnownFailureTest("There can be errors in the numpy " +
"import stack, " +
"see issues #1891 and #2679")
except TimeoutException:
raise KnownFailureTest("pipe timed out, known issue")
finally:
signal.signal(signal.SIGALRM, old_handler)


@cleanup
Expand Down