Skip to content

Commit 012383f

Browse files
committed
add compression size test case
1 parent 498451d commit 012383f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/io/json/test_compression.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ def test_compression_roundtrip(compression):
2121
assert_frame_equal(df, pd.read_json(result))
2222

2323

24+
def test_to_csv_compression_size(compression):
25+
26+
df = pd.concat(100 * [pd.DataFrame([[0.123456, 0.234567, 0.567567],
27+
[12.32112, 123123.2, 321321.2]],
28+
columns=['X', 'Y', 'Z'])],
29+
ignore_index=True)
30+
31+
with tm.ensure_clean() as filename:
32+
import os
33+
df.to_json(filename, compression=compression)
34+
file_size = os.path.getsize(filename)
35+
36+
if compression:
37+
df.to_json(filename, compression=None)
38+
uncompressed_file_size = os.path.getsize(filename)
39+
assert uncompressed_file_size > file_size
40+
41+
2442
def test_read_zipped_json():
2543
uncompressed_path = tm.get_data_path("tsframe_v012.json")
2644
uncompressed_df = pd.read_json(uncompressed_path)

0 commit comments

Comments
 (0)