@@ -231,13 +231,33 @@ def test_standardize_mapping():
231
231
columns = ['X' , 'Y' , 'Z' ]),
232
232
Series (100 * [0.123456 , 0.234567 , 0.567567 ], name = 'X' )])
233
233
@pytest .mark .parametrize ('method' , ['to_pickle' , 'to_json' , 'to_csv' ])
234
- def test_compression_size (obj , method , compression ):
235
- if not compression :
236
- pytest .skip ("only test compression case." )
234
+ def test_compression_size (obj , method , compression_only ):
237
235
238
236
with tm .ensure_clean () as filename :
239
- getattr (obj , method )(filename , compression = compression )
237
+ getattr (obj , method )(filename , compression = compression_only )
240
238
compressed = os .path .getsize (filename )
241
239
getattr (obj , method )(filename , compression = None )
242
240
uncompressed = os .path .getsize (filename )
243
241
assert uncompressed > compressed
242
+
243
+
244
+ @pytest .mark .parametrize ('obj' , [
245
+ DataFrame (100 * [[0.123456 , 0.234567 , 0.567567 ],
246
+ [12.32112 , 123123.2 , 321321.2 ]],
247
+ columns = ['X' , 'Y' , 'Z' ]),
248
+ Series (100 * [0.123456 , 0.234567 , 0.567567 ], name = 'X' )])
249
+ @pytest .mark .parametrize ('method' , ['to_csv' ])
250
+ def test_compression_size_fh (obj , method , compression_only ):
251
+
252
+ with tm .ensure_clean () as filename :
253
+ with open (filename , 'w' ) as fh :
254
+ getattr (obj , method )(fh , compression = compression_only )
255
+ # GH 17778
256
+ assert fh .closed
257
+ compressed = os .path .getsize (filename )
258
+ with tm .ensure_clean () as filename :
259
+ with open (filename , 'w' ) as fh :
260
+ getattr (obj , method )(fh , compression = None )
261
+ assert not fh .closed
262
+ uncompressed = os .path .getsize (filename )
263
+ assert uncompressed > compressed
0 commit comments