69
69
from pandas .io .sas .sas_xport import XportReader
70
70
from pandas .io .stata import StataReader
71
71
72
- from . import lxml_skip
72
+ from . import (
73
+ lxml_skip ,
74
+ pytest_warns_bounded ,
75
+ )
73
76
74
77
DF = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [0.0 , 0.0 , 0.0 ]})
75
78
CWD = os .path .split (os .path .abspath (__file__ ))[0 ]
78
81
@pytest .mark .skipif (WINDOWS , reason = "ORC not available on windows" )
79
82
def test_orc ():
80
83
with ensure_clean () as path :
81
- check (assert_type (DF .to_orc (path ), None ), type (None ))
84
+ with pytest_warns_bounded (
85
+ FutureWarning ,
86
+ match = "is_sparse is deprecated and will be removed in a future version" ,
87
+ lower = "2.0.99" ,
88
+ ):
89
+ check (assert_type (DF .to_orc (path ), None ), type (None ))
82
90
check (assert_type (read_orc (path ), DataFrame ), DataFrame )
83
91
84
92
85
93
@pytest .mark .skipif (WINDOWS , reason = "ORC not available on windows" )
86
94
def test_orc_path ():
87
95
with ensure_clean () as path :
88
96
pathlib_path = Path (path )
89
- check (assert_type (DF .to_orc (pathlib_path ), None ), type (None ))
97
+ with pytest_warns_bounded (
98
+ FutureWarning ,
99
+ match = "is_sparse is deprecated and will be removed in a future version" ,
100
+ lower = "2.0.99" ,
101
+ ):
102
+ check (assert_type (DF .to_orc (pathlib_path ), None ), type (None ))
90
103
check (assert_type (read_orc (pathlib_path ), DataFrame ), DataFrame )
91
104
92
105
93
106
@pytest .mark .skipif (WINDOWS , reason = "ORC not available on windows" )
94
107
def test_orc_buffer ():
95
108
with ensure_clean () as path :
96
109
file_w = open (path , "wb" )
97
- check (assert_type (DF .to_orc (file_w ), None ), type (None ))
110
+ with pytest_warns_bounded (
111
+ FutureWarning ,
112
+ match = "is_sparse is deprecated and will be removed in a future version" ,
113
+ lower = "2.0.99" ,
114
+ ):
115
+ check (assert_type (DF .to_orc (file_w ), None ), type (None ))
98
116
file_w .close ()
99
117
100
118
file_r = open (path , "rb" )
@@ -105,13 +123,23 @@ def test_orc_buffer():
105
123
@pytest .mark .skipif (WINDOWS , reason = "ORC not available on windows" )
106
124
def test_orc_columns ():
107
125
with ensure_clean () as path :
108
- check (assert_type (DF .to_orc (path , index = False ), None ), type (None ))
126
+ with pytest_warns_bounded (
127
+ FutureWarning ,
128
+ match = "is_sparse is deprecated and will be removed in a future version" ,
129
+ lower = "2.0.99" ,
130
+ ):
131
+ check (assert_type (DF .to_orc (path , index = False ), None ), type (None ))
109
132
check (assert_type (read_orc (path , columns = ["a" ]), DataFrame ), DataFrame )
110
133
111
134
112
135
@pytest .mark .skipif (WINDOWS , reason = "ORC not available on windows" )
113
136
def test_orc_bytes ():
114
- check (assert_type (DF .to_orc (index = False ), bytes ), bytes )
137
+ with pytest_warns_bounded (
138
+ FutureWarning ,
139
+ match = "is_sparse is deprecated and will be removed in a future version" ,
140
+ lower = "2.0.99" ,
141
+ ):
142
+ check (assert_type (DF .to_orc (index = False ), bytes ), bytes )
115
143
116
144
117
145
@lxml_skip
@@ -504,27 +532,47 @@ def test_json_chunk():
504
532
505
533
def test_parquet ():
506
534
with ensure_clean () as path :
507
- check (assert_type (DF .to_parquet (path ), None ), type (None ))
535
+ with pytest_warns_bounded (
536
+ FutureWarning ,
537
+ match = "is_sparse is deprecated and will be removed in a future version" ,
538
+ lower = "2.0.99" ,
539
+ ):
540
+ check (assert_type (DF .to_parquet (path ), None ), type (None ))
541
+ check (assert_type (DF .to_parquet (), bytes ), bytes )
508
542
check (assert_type (read_parquet (path ), DataFrame ), DataFrame )
509
- check (assert_type (DF .to_parquet (), bytes ), bytes )
510
543
511
544
512
545
def test_parquet_options ():
513
546
with ensure_clean (".parquet" ) as path :
514
- check (
515
- assert_type (DF .to_parquet (path , compression = None , index = True ), None ),
516
- type (None ),
517
- )
547
+ with pytest_warns_bounded (
548
+ FutureWarning ,
549
+ match = "is_sparse is deprecated and will be removed in a future version" ,
550
+ lower = "2.0.99" ,
551
+ ):
552
+ check (
553
+ assert_type (DF .to_parquet (path , compression = None , index = True ), None ),
554
+ type (None ),
555
+ )
518
556
check (assert_type (read_parquet (path ), DataFrame ), DataFrame )
519
557
520
558
521
559
def test_feather ():
522
560
with ensure_clean () as path :
523
- check (assert_type (DF .to_feather (path ), None ), type (None ))
561
+ with pytest_warns_bounded (
562
+ FutureWarning ,
563
+ match = "is_sparse is deprecated and will be removed in a future version" ,
564
+ lower = "2.0.99" ,
565
+ ):
566
+ check (assert_type (DF .to_feather (path ), None ), type (None ))
524
567
check (assert_type (read_feather (path ), DataFrame ), DataFrame )
525
568
check (assert_type (read_feather (path , columns = ["a" ]), DataFrame ), DataFrame )
526
569
bio = io .BytesIO ()
527
- check (assert_type (DF .to_feather (bio ), None ), type (None ))
570
+ with pytest_warns_bounded (
571
+ FutureWarning ,
572
+ match = "is_sparse is deprecated and will be removed in a future version" ,
573
+ lower = "2.0.00" ,
574
+ ):
575
+ check (assert_type (DF .to_feather (bio ), None ), type (None ))
528
576
bio .seek (0 )
529
577
check (assert_type (read_feather (bio ), DataFrame ), DataFrame )
530
578
@@ -1322,13 +1370,22 @@ def test_all_read_without_lxml_dtype_backend() -> None:
1322
1370
con .close ()
1323
1371
1324
1372
if not WINDOWS :
1325
- check (assert_type (DF .to_orc (path ), None ), type (None ))
1373
+ with pytest_warns_bounded (
1374
+ FutureWarning ,
1375
+ match = "is_sparse is deprecated and will be removed in a future version" ,
1376
+ lower = "2.0.99" ,
1377
+ ):
1378
+ check (assert_type (DF .to_orc (path ), None ), type (None ))
1326
1379
check (
1327
1380
assert_type (read_orc (path , dtype_backend = "numpy_nullable" ), DataFrame ),
1328
1381
DataFrame ,
1329
1382
)
1330
-
1331
- check (assert_type (DF .to_feather (path ), None ), type (None ))
1383
+ with pytest_warns_bounded (
1384
+ FutureWarning ,
1385
+ match = "is_sparse is deprecated and will be removed in a future version" ,
1386
+ lower = "2.0.99" ,
1387
+ ):
1388
+ check (assert_type (DF .to_feather (path ), None ), type (None ))
1332
1389
check (
1333
1390
assert_type (read_feather (path , dtype_backend = "pyarrow" ), DataFrame ),
1334
1391
DataFrame ,
0 commit comments