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

Skip to content

Commit 1bb5bb5

Browse files
committed
Fix #951: make tests to clean temp files properly
1 parent e69b591 commit 1bb5bb5

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

numpy/core/tests/test_memmap.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ def setUp(self):
1414
self.data = arange(12, dtype=self.dtype)
1515
self.data.resize(self.shape)
1616

17+
def tearDown(self):
18+
self.tmpfp.close()
19+
1720
def test_roundtrip(self):
1821
# Write data to file
1922
fp = memmap(self.tmpfp, dtype=self.dtype, mode='w+',

numpy/core/tests/test_multiarray.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import tempfile
22
import sys
3+
import os
34
import numpy as np
45
from numpy.testing import *
56
from numpy.core import *
@@ -832,6 +833,7 @@ def test_file(self):
832833
tmp_file.flush()
833834
y = np.fromfile(tmp_file.name,dtype=self.dtype)
834835
assert_array_equal(y,self.x.flat)
836+
tmp_file.close()
835837

836838
def test_filename(self):
837839
filename = tempfile.mktemp()
@@ -840,6 +842,7 @@ def test_filename(self):
840842
f.close()
841843
y = np.fromfile(filename,dtype=self.dtype)
842844
assert_array_equal(y,self.x.flat)
845+
os.unlink(filename)
843846

844847
def test_malformed(self):
845848
filename = tempfile.mktemp()
@@ -848,6 +851,7 @@ def test_malformed(self):
848851
f.close()
849852
y = np.fromfile(filename, sep=' ')
850853
assert_array_equal(y, [1.234, 1.])
854+
os.unlink(filename)
851855

852856
class TestFromBuffer(TestCase):
853857
def tst_basic(self,buffer,expected,kwargs):

0 commit comments

Comments
 (0)