Skip to content

Commit 2dc9e0e

Browse files
Vikram Shirgurjreback
Vikram Shirgur
authored andcommitted
BUG: Use temp files in all pytables tests to fix (GH9992).
1 parent 34bb831 commit 2dc9e0e

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

doc/source/whatsnew/v0.16.1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Bug Fixes
278278
- Bug in ``DataFrameFormatter._get_formatted_index`` with not applying ``max_colwidth`` to the ``DataFrame`` index (:issue:`7856`)
279279
- Bug in ``.loc`` with a read-only ndarray data source (:issue:`10043`)
280280
- Bug in ``groupby.apply()`` that would raise if a passed user defined function either returned only ``None`` (for all input). (:issue:`9685`)
281-
281+
- Always use temporary files in pytables tests (:issue:`9992`)
282282
- Bug in plotting continuously using ``secondary_y`` may not show legend properly. (:issue:`9610`, :issue:`9779`)
283283
- Bug in ``DataFrame.plot(kind="hist")`` results in ``TypeError`` when ``DataFrame`` contains non-numeric columns (:issue:`9853`)
284284
- Bug where repeated plotting of ``DataFrame`` with a ``DatetimeIndex`` may raise ``TypeError`` (:issue:`9852`)

pandas/core/strings.py

+1
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ def __iter__(self):
10011001
g = self.get(i)
10021002

10031003
def _wrap_result(self, result, **kwargs):
1004+
10041005
# leave as it is to keep extract and get_dummies results
10051006
# can be merged to _wrap_result_expand in v0.17
10061007
from pandas.core.series import Series

pandas/io/tests/test_pytables.py

+22-20
Original file line numberDiff line numberDiff line change
@@ -156,50 +156,51 @@ def tearDown(self):
156156
pass
157157

158158
def test_factory_fun(self):
159+
path = create_tempfile(self.path)
159160
try:
160-
with get_store(self.path) as tbl:
161+
with get_store(path) as tbl:
161162
raise ValueError('blah')
162163
except ValueError:
163164
pass
164165
finally:
165-
safe_remove(self.path)
166+
safe_remove(path)
166167

167168
try:
168-
with get_store(self.path) as tbl:
169+
with get_store(path) as tbl:
169170
tbl['a'] = tm.makeDataFrame()
170171

171-
with get_store(self.path) as tbl:
172+
with get_store(path) as tbl:
172173
self.assertEqual(len(tbl), 1)
173174
self.assertEqual(type(tbl['a']), DataFrame)
174175
finally:
175176
safe_remove(self.path)
176177

177178
def test_context(self):
179+
path = create_tempfile(self.path)
178180
try:
179-
with HDFStore(self.path) as tbl:
181+
with HDFStore(path) as tbl:
180182
raise ValueError('blah')
181183
except ValueError:
182184
pass
183185
finally:
184-
safe_remove(self.path)
186+
safe_remove(path)
185187

186188
try:
187-
with HDFStore(self.path) as tbl:
189+
with HDFStore(path) as tbl:
188190
tbl['a'] = tm.makeDataFrame()
189191

190-
with HDFStore(self.path) as tbl:
192+
with HDFStore(path) as tbl:
191193
self.assertEqual(len(tbl), 1)
192194
self.assertEqual(type(tbl['a']), DataFrame)
193195
finally:
194-
safe_remove(self.path)
196+
safe_remove(path)
195197

196198
def test_conv_read_write(self):
197-
199+
path = create_tempfile(self.path)
198200
try:
199-
200201
def roundtrip(key, obj,**kwargs):
201-
obj.to_hdf(self.path, key,**kwargs)
202-
return read_hdf(self.path, key)
202+
obj.to_hdf(path, key,**kwargs)
203+
return read_hdf(path, key)
203204

204205
o = tm.makeTimeSeries()
205206
assert_series_equal(o, roundtrip('series',o))
@@ -215,12 +216,12 @@ def roundtrip(key, obj,**kwargs):
215216

216217
# table
217218
df = DataFrame(dict(A=lrange(5), B=lrange(5)))
218-
df.to_hdf(self.path,'table',append=True)
219-
result = read_hdf(self.path, 'table', where = ['index>2'])
219+
df.to_hdf(path,'table',append=True)
220+
result = read_hdf(path, 'table', where = ['index>2'])
220221
assert_frame_equal(df[df.index>2],result)
221222

222223
finally:
223-
safe_remove(self.path)
224+
safe_remove(path)
224225

225226
def test_long_strings(self):
226227

@@ -4329,13 +4330,14 @@ def do_copy(f = None, new_f = None, keys = None, propindexes = True, **kwargs):
43294330
df = tm.makeDataFrame()
43304331

43314332
try:
4332-
st = HDFStore(self.path)
4333+
path = create_tempfile(self.path)
4334+
st = HDFStore(path)
43334335
st.append('df', df, data_columns = ['A'])
43344336
st.close()
4335-
do_copy(f = self.path)
4336-
do_copy(f = self.path, propindexes = False)
4337+
do_copy(f = path)
4338+
do_copy(f = path, propindexes = False)
43374339
finally:
4338-
safe_remove(self.path)
4340+
safe_remove(path)
43394341

43404342
def test_legacy_table_write(self):
43414343
raise nose.SkipTest("cannot write legacy tables")

0 commit comments

Comments
 (0)