8000 Decrease output when running `pytest -s`. · matplotlib/matplotlib@fa83f05 · GitHub
[go: up one dir, main page]

Skip to content

Commit fa83f05

Browse files
committed
Decrease output when running pytest -s.
The explicit cleanup() animation tmpdir on teardown avoids emitting ResourceWarnings when running e.g. `pytest lib/matplotlib/tests/test_animation.py -s`. The call to print in test_text is unneeded. The one in test_pylab doesn't actually print normally, but I simplified the test while at it.
1 parent 80eabbc commit fa83f05

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

lib/matplotlib/animation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ def setup(self, fig, outfile, dpi=None, frame_prefix=None,
441441
self._temp_paths = list()
442442
self.fname_format_str = '%s%%07d.%s'
443443

444+
def __del__(self):
445+
if self._tmpdir:
446+
self._tmpdir.cleanup()
447+
444448
@cbook.deprecated("3.3")
445449
@property
446450
def clear_temp(self):

lib/matplotlib/tests/test_basic.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def test_simple():
1111

1212
def test_override_builtins():
1313
import pylab
14-
1514
ok_to_override = {
1615
'__name__',
1716
'__doc__',
@@ -23,15 +22,9 @@ def test_override_builtins():
2322
'sum',
2423
'divmod'
2524
}
26-
overridden = False
27-
for key in dir(pylab):
28-
if key in dir(builtins):
29-
if (getattr(pylab, key) != getattr(builtins, key) and
30-
key not in ok_to_override):
31-
print("'%s' was overridden in globals()." % key)
32-
overridden = True
33-
34-
ADEC assert not overridden
25+
overridden = {key for key in {*dir(pylab)} & {*dir(builtins)}
26+
if getattr(pylab, key) != getattr(builtins, key)}
27+
assert overridden <= ok_to_override
3528

3629

3730
def test_lazy_imports():

lib/matplotlib/tests/test_text.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,7 @@ def test_text_as_text_opacity():
599599
def test_text_repr():
600600
# smoketest to make sure text repr doesn't error for category
601601
plt.plot(['A', 'B'], [1, 2])
602-
txt = plt.text(['A'], 0.5, 'Boo')
603-
print(txt)
602+
repr(plt.text(['A'], 0.5, 'Boo'))
604603

605604

606605
def test_annotation_update():

0 commit comments

Comments
 (0)
0