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

Skip to content

Commit b9d944b

Browse files
committed
TST: use pytest tmpdir fixture instead of tempdir + shutil
1 parent a17787b commit b9d944b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/matplotlib/tests/test_png.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
from six import BytesIO
66
import glob
77
import os
8-
import shutil
98
import numpy as np
109
import pytest
1110

1211
from matplotlib.testing.decorators import image_comparison
1312
from matplotlib import pyplot as plt
1413
import matplotlib.cm as cm
15-
import tempfile
1614
import sys
1715
on_win = (sys.platform == 'win32')
1816

@@ -49,8 +47,8 @@ def test_imread_png_uint16():
4947
assert np.sum(img.flatten()) == 134184960
5048

5149

52-
def test_truncated_file():
53-
d = tempfile.mkdtemp()
50+
def test_truncated_file(tmpdir):
51+
d = tmpdir.mkdir('test')
5452
fname = os.path.join(d, 'test.png')
5553
fname_t = os.path.join(d, 'test_truncated.png')
5654
plt.savefig(fname)
@@ -62,8 +60,6 @@ def test_truncated_file():
6260
with pytest.raises(Exception):
6361
plt.imread(fname_t)
6462

65-
shutil.rmtree(d)
66-
6763

6864
def test_truncated_buffer():
6965
b = BytesIO()

0 commit comments

Comments
 (0)