@@ -156,50 +156,51 @@ def tearDown(self):
156
156
pass
157
157
158
158
def test_factory_fun (self ):
159
+ path = create_tempfile (self .path )
159
160
try :
160
- with get_store (self . path ) as tbl :
161
+ with get_store (path ) as tbl :
161
162
raise ValueError ('blah' )
162
163
except ValueError :
163
164
pass
164
165
finally :
165
- safe_remove (self . path )
166
+ safe_remove (path )
166
167
167
168
try :
168
- with get_store (self . path ) as tbl :
169
+ with get_store (path ) as tbl :
169
170
tbl ['a' ] = tm .makeDataFrame ()
170
171
171
- with get_store (self . path ) as tbl :
172
+ with get_store (path ) as tbl :
172
173
self .assertEqual (len (tbl ), 1 )
173
174
self .assertEqual (type (tbl ['a' ]), DataFrame )
174
175
finally :
175
176
safe_remove (self .path )
176
177
177
178
def test_context (self ):
179
+ path = create_tempfile (self .path )
178
180
try :
179
- with HDFStore (self . path ) as tbl :
181
+ with HDFStore (path ) as tbl :
180
182
raise ValueError ('blah' )
181
183
except ValueError :
182
184
pass
183
185
finally :
184
- safe_remove (self . path )
186
+ safe_remove (path )
185
187
186
188
try :
187
- with HDFStore (self . path ) as tbl :
189
+ with HDFStore (path ) as tbl :
188
190
tbl ['a' ] = tm .makeDataFrame ()
189
191
190
- with HDFStore (self . path ) as tbl :
192
+ with HDFStore (path ) as tbl :
191
193
self .assertEqual (len (tbl ), 1 )
192
194
self .assertEqual (type (tbl ['a' ]), DataFrame )
193
195
finally :
194
- safe_remove (self . path )
196
+ safe_remove (path )
195
197
196
198
def test_conv_read_write (self ):
197
-
199
+ path = create_tempfile ( self . path )
198
200
try :
199
-
200
201
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 )
203
204
204
205
o = tm .makeTimeSeries ()
205
206
assert_series_equal (o , roundtrip ('series' ,o ))
@@ -215,12 +216,12 @@ def roundtrip(key, obj,**kwargs):
215
216
216
217
# table
217
218
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' ])
220
221
assert_frame_equal (df [df .index > 2 ],result )
221
222
222
223
finally :
223
- safe_remove (self . path )
224
+ safe_remove (path )
224
225
225
226
def test_long_strings (self ):
226
227
@@ -4329,13 +4330,14 @@ def do_copy(f = None, new_f = None, keys = None, propindexes = True, **kwargs):
4329
4330
df = tm .makeDataFrame ()
4330
4331
4331
4332
try :
4332
- st = HDFStore (self .path )
4333
+ path = create_tempfile (self .path )
4334
+ st = HDFStore (path )
4333
4335
st .append ('df' , df , data_columns = ['A' ])
4334
4336
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 )
4337
4339
finally :
4338
- safe_remove (self . path )
4340
+ safe_remove (path )
4339
4341
4340
4342
def test_legacy_table_write (self ):
4341
4343
raise nose .SkipTest ("cannot write legacy tables" )
0 commit comments