Skip to content

Commit 5993cb2

Browse files
authored
Merge d1958ff into e360db9
2 parents e360db9 + d1958ff commit 5993cb2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

mayavi/tests/test_csv_sniff.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def test_API(self):
6666
dtype=[('A', float), ('B', float), ('C', float)])
6767
self.assertNamedClose(x, y)
6868

69-
y = loadtxt(fo, **s.kwds())
69+
with open(fo) as fh:
70+
y = loadtxt(fh, **s.kwds())
7071
self.assertNamedClose(x, y)
7172

7273
y = loadtxt_unknown(fo)
@@ -154,7 +155,8 @@ def check(self, name, skip_if_win=False):
154155
if not sys.platform.startswith('win'):
155156
nan = float('nan') # must be in namespace for some .py files
156157

157-
d = eval(open(f_py).read())
158+
with open(f_py) as fh:
159+
d = eval(fh.read())
158160

159161
self.assertEqual(d['kwds'], s.kwds())
160162
self.assertNamedClose(d['array'], s.loadtxt())

mayavi/tools/data_wizards/csv_sniff.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ def loadtxt(self):
171171
""" Return the array (by using numpy.loadtxt), using the sniffed
172172
information in the keyword arguments.
173173
"""
174-
return loadtxt(self._filename, **self.kwds())
174+
with open(self._filename) as fh:
175+
data = loadtxt(fh, **self.kwds())
176+
return data
175177

176178

177179
def loadtxt_unknown(filename, verbose=0):

0 commit comments

Comments
 (0)