@@ -10,14 +10,15 @@ def test_compression_roundtrip(compression):
10
10
[12.32112 , 123123.2 , 321321.2 ]],
11
11
index = ['A' , 'B' ], columns = ['X' , 'Y' , 'Z' ])
12
12
13
- with tm .ensure_clean () as path :
14
- df .to_json (path , compression = compression )
15
- assert_frame_equal (df , pd .read_json (path , compression = compression ))
13
+ if compression != 'zip' :
14
+ with tm .ensure_clean () as path :
15
+ df .to_json (path , compression = compression )
16
+ assert_frame_equal (df , pd .read_json (path , compression = compression ))
16
17
17
- # explicitly ensure file was compressed.
18
- with tm .decompress_file (path , compression ) as fh :
19
- result = fh .read ().decode ('utf8' )
20
- assert_frame_equal (df , pd .read_json (result ))
18
+ # explicitly ensure file was compressed.
19
+ with tm .decompress_file (path , compression ) as fh :
20
+ result = fh .read ().decode ('utf8' )
21
+ assert_frame_equal (df , pd .read_json (result ))
21
22
22
23
23
24
def test_compress_zip_value_error ():
@@ -61,22 +62,29 @@ def test_with_s3_url(compression):
61
62
62
63
63
64
def test_lines_with_compression (compression ):
64
- with tm .ensure_clean () as path :
65
- df = pd .read_json ('{"a": [1, 2, 3], "b": [4, 5, 6]}' )
66
- df .to_json (path , orient = 'records' , lines = True , compression = compression )
67
- roundtripped_df = pd .read_json (path , lines = True ,
68
- compression = compression )
69
- assert_frame_equal (df , roundtripped_df )
65
+
66
+ if compression != 'zip' :
67
+ with tm .ensure_clean () as path :
68
+ df = pd .read_json ('{"a": [1, 2, 3], "b": [4, 5, 6]}' )
69
+ df .to_json (path , orient = 'records' , lines = True ,
70
+ compression = compression )
71
+ roundtripped_df = pd .read_json (path , lines = True ,
72
+ compression = compression )
73
+ assert_frame_equal (df , roundtripped_df )
70
74
71
75
72
76
def test_chunksize_with_compression (compression ):
73
- with tm .ensure_clean () as path :
74
- df = pd .read_json ('{"a": ["foo", "bar", "baz"], "b": [4, 5, 6]}' )
75
- df .to_json (path , orient = 'records' , lines = True , compression = compression )
76
77
77
- roundtripped_df = pd .concat (pd .read_json (path , lines = True , chunksize = 1 ,
78
- compression = compression ))
79
- assert_frame_equal (df , roundtripped_df )
78
+ if compression != 'zip' :
79
+ with tm .ensure_clean () as path :
80
+ df = pd .read_json ('{"a": ["foo", "bar", "baz"], "b": [4, 5, 6]}' )
81
+ df .to_json (path , orient = 'records' , lines = True ,
82
+ compression = compression )
83
+
84
+ roundtripped_df = pd .concat (pd .read_json (path , lines = True ,
85
+ chunksize = 1 ,
86
+ compression = compression ))
87
+ assert_frame_equal (df , roundtripped_df )
80
88
81
89
82
90
def test_write_unsupported_compression_type ():
0 commit comments