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

Skip to content

Commit 71420d2

Browse files
committed
Add suggestions to MovieWriterRegistry lookup errors
1 parent f1ce720 commit 71420d2

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/matplotlib/animation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def list(self):
117117

118118
def __getitem__(self, name):
119119
"""Get an available writer class from its name."""
120+
_api.check_in_list(self._registered, writer=name)
120121
if self.is_available(name):
121122
return self._registered[name]
122123
raise RuntimeError(f"Requested MovieWriter ({name}) not available")

lib/matplotlib/tests/test_animation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ def animate(i):
4444
return klass(fig=fig, func=animate, init_func=init, **kwargs)
4545

4646

47+
def test_invalid_writer():
48+
# Note, this triggers for Animation.save as well, but this is a lighter test.
49+
with pytest.raises(ValueError,
50+
match=r"'pllow' is not a valid value for writer\. "
51+
r"Did you mean: 'pillow'\?"):
52+
animation.writers['pllow']
53+
54+
4755
class NullMovieWriter(animation.AbstractMovieWriter):
4856
"""
4957
A minimal MovieWriter. It doesn't actually write anything.

0 commit comments

Comments
 (0)