Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d30134f

Browse filesBrowse files
author
Umair Idris
committed
Cleanup test dirs
1 parent 28d9f53 commit d30134f
Copy full SHA for d30134f

File tree

Expand file treeCollapse file tree

1 file changed

+26
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-17
lines changed

‎lib/matplotlib/tests/test_backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_bases.py
+26-17Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from nose.tools import assert_equal
1010

1111
import numpy as np
12-
import tempfile
1312
import os
13+
import shutil
14+
import tempfile
15+
1416

1517
def test_uses_per_path():
1618
id = transforms.Affine2D()
@@ -52,28 +54,35 @@ def check(master_transform, paths, all_transforms,
5254
check(id, paths, tforms, offsets, [], [])
5355
check(id, paths, tforms, offsets, facecolors[0:1], edgecolors)
5456

57+
5558
@cleanup
5659
def test_get_default_filename():
57-
test_dir = tempfile.mkdtemp()
58-
plt.rcParams['savefig.directory'] = test_dir
59-
fig = plt.figure()
60-
canvas = FigureCanvasBase(fig)
61-
filename = canvas.get_default_filename()
62-
assert_equal(filename, 'image.png')
60+
try:
61+
test_dir = tempfile.mkdtemp()
62+
plt.rcParams['savefig.directory'] = test_dir
63+
fig = plt.figure()
64+
canvas = FigureCanvasBase(fig)
65+
filename = canvas.get_default_filename()
66+
assert_equal(filename, 'image.png')
67+
finally:
68+
shutil.rmtree(test_dir)
69+
6370

6471
@cleanup
65-
def test_get_default_filename_already_existing():
72+
def test_get_default_filename_already_exists():
6673
# From #3068: Suggest non-existing default filename
67-
test_dir = tempfile.mkdtemp()
68-
plt.rcParams['savefig.directory'] = test_dir
69-
fig = plt.figure()
70-
canvas = FigureCanvasBase(fig)
71-
72-
# create 'image.png' in figure's save dir
73-
with open(os.path.join(test_dir, 'image.png'), 'a'):
74-
filename = canvas.get_default_filename()
75-
assert_equal(filename, 'image-1.png')
74+
try:
75+
test_dir = tempfile.mkdtemp()
76+
plt.rcParams['savefig.directory'] = test_dir
77+
fig = plt.figure()
78+
canvas = FigureCanvasBase(fig)
7679

80+
# create 'image.png' in figure's save dir
81+
with open(os.path.join(test_dir, 'image.png'), 'a'):
82+
filename = canvas.get_default_filename()
83+
assert_equal(filename, 'image-1.png')
84+
finally:
85+
shutil.rmtree(test_dir)
7786

7887
if __name__ == "__main__":
7988
import nose

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.