55from pandas .util .testing import assert_frame_equal , assert_raises_regex
66
77
8- def test_compression_roundtrip (compression ):
8+ def test_compression_roundtrip (compression_no_zip ):
99 df = pd .DataFrame ([[0.123456 , 0.234567 , 0.567567 ],
1010 [12.32112 , 123123.2 , 321321.2 ]],
1111 index = ['A' , 'B' ], columns = ['X' , 'Y' , 'Z' ])
1212
1313 with tm .ensure_clean () as path :
14- df .to_json (path , compression = compression )
15- assert_frame_equal (df , pd .read_json (path , compression = compression ))
14+ df .to_json (path , compression = compression_no_zip )
15+ assert_frame_equal (df , pd .read_json (path ,
16+ compression = compression_no_zip ))
1617
1718 # explicitly ensure file was compressed.
18- with tm .decompress_file (path , compression ) as fh :
19+ with tm .decompress_file (path , compression_no_zip ) as fh :
1920 result = fh .read ().decode ('utf8' )
2021 assert_frame_equal (df , pd .read_json (result ))
2122
@@ -40,7 +41,7 @@ def test_read_zipped_json():
4041 assert_frame_equal (uncompressed_df , compressed_df )
4142
4243
43- def test_with_s3_url (compression ):
44+ def test_with_s3_url (compression_no_zip ):
4445 boto3 = pytest .importorskip ('boto3' )
4546 pytest .importorskip ('s3fs' )
4647 moto = pytest .importorskip ('moto' )
@@ -51,31 +52,36 @@ def test_with_s3_url(compression):
5152 bucket = conn .create_bucket (Bucket = "pandas-test" )
5253
5354 with tm .ensure_clean () as path :
54- df .to_json (path , compression = compression )
55+ df .to_json (path , compression = compression_no_zip )
5556 with open (path , 'rb' ) as f :
5657 bucket .put_object (Key = 'test-1' , Body = f )
5758
5859 roundtripped_df = pd .read_json ('s3://pandas-test/test-1' ,
59- compression = compression )
60+ compression = compression_no_zip )
6061 assert_frame_equal (df , roundtripped_df )
6162
6263
63- def test_lines_with_compression (compression ):
64+ def test_lines_with_compression (compression_no_zip ):
65+
6466 with tm .ensure_clean () as path :
6567 df = pd .read_json ('{"a": [1, 2, 3], "b": [4, 5, 6]}' )
66- df .to_json (path , orient = 'records' , lines = True , compression = compression )
68+ df .to_json (path , orient = 'records' , lines = True ,
69+ compression = compression_no_zip )
6770 roundtripped_df = pd .read_json (path , lines = True ,
68- compression = compression )
71+ compression = compression_no_zip )
6972 assert_frame_equal (df , roundtripped_df )
7073
7174
72- def test_chunksize_with_compression (compression ):
75+ def test_chunksize_with_compression (compression_no_zip ):
76+
7377 with tm .ensure_clean () as path :
7478 df = pd .read_json ('{"a": ["foo", "bar", "baz"], "b": [4, 5, 6]}' )
75- df .to_json (path , orient = 'records' , lines = True , compression = compression )
79+ df .to_json (path , orient = 'records' , lines = True ,
80+ compression = compression_no_zip )
7681
77- roundtripped_df = pd .concat (pd .read_json (path , lines = True , chunksize = 1 ,
78- compression = compression ))
82+ res = pd .read_json (path , lines = True , chunksize = 1 ,
83+ compression = compression_no_zip )
84+ roundtripped_df = pd .concat (res )
7985 assert_frame_equal (df , roundtripped_df )
8086
8187
0 commit comments