19
19
import pyarrow as pa
20
20
import pytest
21
21
22
- from tests .system . utils import assert_pandas_df_equal , convert_pandas_dtypes
22
+ from tests .system import utils
23
23
24
24
try :
25
25
import pandas_gbq # type: ignore
@@ -115,7 +115,6 @@ def test_to_pandas_batches_w_correct_dtypes(scalars_df_default_index):
115
115
pd .testing .assert_series_equal (actual , expected )
116
116
117
117
118
- @pytest .mark .skip (reason = "Disable to unblock kokoro tests" )
119
118
@pytest .mark .parametrize (
120
119
("index" ),
121
120
[True , False ],
@@ -150,12 +149,12 @@ def test_to_csv_index(
150
149
# read_csv will decode into bytes inproperly, convert_pandas_dtypes will encode properly from string
151
150
dtype .pop ("bytes_col" )
152
151
gcs_df = pd .read_csv (
153
- path ,
152
+ utils . get_first_file_from_wildcard ( path ) ,
154
153
dtype = dtype ,
155
154
date_format = {"timestamp_col" : "YYYY-MM-DD HH:MM:SS Z" },
156
155
index_col = index_col ,
157
156
)
158
- convert_pandas_dtypes (gcs_df , bytes_col = True )
157
+ utils . convert_pandas_dtypes (gcs_df , bytes_col = True )
159
158
gcs_df .index .name = scalars_df .index .name
160
159
161
160
scalars_pandas_df = scalars_pandas_df .copy ()
@@ -164,7 +163,6 @@ def test_to_csv_index(
164
163
pd .testing .assert_frame_equal (gcs_df , scalars_pandas_df )
165
164
166
165
167
- @pytest .mark .skip (reason = "Disable to unblock kokoro tests" )
168
166
def test_to_csv_tabs (
169
167
scalars_dfs : Tuple [bigframes .dataframe .DataFrame , pd .DataFrame ],
170
168
gcs_folder : str ,
@@ -189,13 +187,13 @@ def test_to_csv_tabs(
189
187
# read_csv will decode into bytes inproperly, convert_pandas_dtypes will encode properly from string
190
188
dtype .pop ("bytes_col" )
191
189
gcs_df = pd .read_csv (
192
- path ,
190
+ utils . get_first_file_from_wildcard ( path ) ,
193
191
sep = "\t " ,
194
192
dtype = dtype ,
195
193
date_format = {"timestamp_col" : "YYYY-MM-DD HH:MM:SS Z" },
196
194
index_col = index_col ,
197
195
)
198
- convert_pandas_dtypes (gcs_df , bytes_col = True )
196
+ utils . convert_pandas_dtypes (gcs_df , bytes_col = True )
199
197
gcs_df .index .name = scalars_df .index .name
200
198
201
199
scalars_pandas_df = scalars_pandas_df .copy ()
@@ -229,7 +227,7 @@ def test_to_gbq_index(scalars_dfs, dataset_id, index):
229
227
else :
230
228
df_out = df_out .sort_values ("rowindex_2" ).reset_index (drop = True )
231
229
232
- convert_pandas_dtypes (df_out , bytes_col = False )
230
+ utils . convert_pandas_dtypes (df_out , bytes_col = False )
233
231
# pd.read_gbq interpets bytes_col as object, reconvert to pyarrow binary
234
232
df_out ["bytes_col" ] = df_out ["bytes_col" ].astype (pd .ArrowDtype (pa .binary ()))
235
233
expected = scalars_pandas_df .copy ()
@@ -415,7 +413,6 @@ def test_to_json_index_invalid_lines(
415
413
scalars_df .to_json (path , index = index )
416
414
417
415
418
- @pytest .mark .skip (reason = "Disable to unblock kokoro tests" )
419
416
@pytest .mark .parametrize (
420
417
("index" ),
421
418
[True , False ],
@@ -435,8 +432,12 @@ def test_to_json_index_records_orient(
435
432
""" Test the `to_json` API with `orient` is `records` and `lines` is True"""
436
433
scalars_df .to_json (path , index = index , orient = "records" , lines = True )
437
434
438
- gcs_df = pd .read_json (path , lines = True , convert_dates = ["datetime_col" ])
439
- convert_pandas_dtypes (gcs_df , bytes_col = True )
435
+ gcs_df = pd .read_json (
436
+ utils .get_first_file_from_wildcard (path ),
437
+ lines = True ,
438
+ convert_dates = ["datetime_col" ],
439
+ )
440
+ utils .convert_pandas_dtypes (gcs_df , bytes_col = True )
440
441
if index and scalars_df .index .name is not None :
441
442
gcs_df = gcs_df .set_index (scalars_df .index .name )
442
443
@@ -474,8 +475,8 @@ def test_to_parquet_index(scalars_dfs, gcs_folder, index):
474
475
# table.
475
476
scalars_df .to_parquet (path , index = index )
476
477
477
- gcs_df = pd .read_parquet (path . replace ( "*" , "000000000000" ))
478
- convert_pandas_dtypes (gcs_df , bytes_col = False )
478
+ gcs_df = pd .read_parquet (utils . get_first_file_from_wildcard ( path ))
479
+ utils . convert_pandas_dtypes (gcs_df , bytes_col = False )
479
480
if index and scalars_df .index .name is not None :
480
481
gcs_df = gcs_df .set_index (scalars_df .index .name )
481
482
@@ -507,7 +508,7 @@ def test_to_sql_query_unnamed_index_included(
507
508
pd_df = scalars_pandas_df_default_index .reset_index (drop = True )
508
509
roundtrip = session .read_gbq (sql , index_col = idx_ids )
509
510
roundtrip .index .names = [None ]
510
- assert_pandas_df_equal (roundtrip .to_pandas (), pd_df , check_index_type = False )
511
+ utils . assert_pandas_df_equal (roundtrip .to_pandas (), pd_df , check_index_type = False )
511
512
512
513
513
514
def test_to_sql_query_named_index_included (
@@ -524,7 +525,7 @@ def test_to_sql_query_named_index_included(
524
525
525
526
pd_df = scalars_pandas_df_default_index .set_index ("rowindex_2" , drop = True )
526
527
roundtrip = session .read_gbq (sql , index_col = idx_ids )
527
- assert_pandas_df_equal (roundtrip .to_pandas (), pd_df )
528
+ utils . assert_pandas_df_equal (roundtrip .to_pandas (), pd_df )
528
529
529
530
530
531
def test_to_sql_query_unnamed_index_excluded (
@@ -539,7 +540,7 @@ def test_to_sql_query_unnamed_index_excluded(
539
540
540
541
pd_df = scalars_pandas_df_default_index .reset_index (drop = True )
541
542
roundtrip = session .read_gbq (sql )
542
- assert_pandas_df_equal (
543
+ utils . assert_pandas_df_equal (
543
544
roundtrip .to_pandas (), pd_df , check_index_type = False , ignore_order = True
544
545
)
545
546
@@ -558,6 +559,6 @@ def test_to_sql_query_named_index_excluded(
558
559
"rowindex_2" , drop = True
559
560
).reset_index (drop = True )
560
561
roundtrip = session .read_gbq (sql )
561
- assert_pandas_df_equal (
562
+ utils . assert_pandas_df_equal (
562
563
roundtrip .to_pandas (), pd_df , check_index_type = False , ignore_order = True
563
564
)
0 commit comments