@@ -3885,30 +3885,30 @@ def test_date_time_astype_int(
38853885 assert bf_result .dtype == "Int64"
38863886
38873887
3888- def test_string_astype_int ():
3889- pd_series = pd .Series (["4" , "-7" , "0" , " -03" ])
3890- bf_series = series .Series (pd_series )
3888+ def test_string_astype_int (session ):
3889+ pd_series = pd .Series (["4" , "-7" , "0" , "-03" ])
3890+ bf_series = series .Series (pd_series , session = session )
38913891
38923892 pd_result = pd_series .astype ("Int64" )
38933893 bf_result = bf_series .astype ("Int64" ).to_pandas ()
38943894
38953895 pd .testing .assert_series_equal (bf_result , pd_result , check_index_type = False )
38963896
38973897
3898- def test_string_astype_float ():
3898+ def test_string_astype_float (session ):
38993899 pd_series = pd .Series (
3900- ["1" , "-1" , "-0" , "000" , " -03.235" , "naN" , "-inf" , "INf" , ".33" , "7.235e-8" ]
3900+ ["1" , "-1" , "-0" , "000" , "-03.235" , "naN" , "-inf" , "INf" , ".33" , "7.235e-8" ]
39013901 )
39023902
3903- bf_series = series .Series (pd_series )
3903+ bf_series = series .Series (pd_series , session = session )
39043904
39053905 pd_result = pd_series .astype ("Float64" )
39063906 bf_result = bf_series .astype ("Float64" ).to_pandas ()
39073907
39083908 pd .testing .assert_series_equal (bf_result , pd_result , check_index_type = False )
39093909
39103910
3911- def test_string_astype_date ():
3911+ def test_string_astype_date (session ):
39123912 if int (pa .__version__ .split ("." )[0 ]) < 15 :
39133913 pytest .skip (
39143914 "Avoid pyarrow.lib.ArrowNotImplementedError: "
@@ -3919,7 +3919,7 @@ def test_string_astype_date():
39193919 pd .ArrowDtype (pa .string ())
39203920 )
39213921
3922- bf_series = series .Series (pd_series )
3922+ bf_series = series .Series (pd_series , session = session )
39233923
39243924 # TODO(b/340885567): fix type error
39253925 pd_result = pd_series .astype ("date32[day][pyarrow]" ) # type: ignore
@@ -3928,20 +3928,20 @@ def test_string_astype_date():
39283928 pd .testing .assert_series_equal (bf_result , pd_result , check_index_type = False )
39293929
39303930
3931- def test_string_astype_datetime ():
3931+ def test_string_astype_datetime (session ):
39323932 pd_series = pd .Series (
39333933 ["2014-08-15 08:15:12" , "2015-08-15 08:15:12.654754" , "2016-02-29 00:00:00" ]
39343934 ).astype (pd .ArrowDtype (pa .string ()))
39353935
3936- bf_series = series .Series (pd_series )
3936+ bf_series = series .Series (pd_series , session = session )
39373937
39383938 pd_result = pd_series .astype (pd .ArrowDtype (pa .timestamp ("us" )))
39393939 bf_result = bf_series .astype (pd .ArrowDtype (pa .timestamp ("us" ))).to_pandas ()
39403940
39413941 pd .testing .assert_series_equal (bf_result , pd_result , check_index_type = False )
39423942
39433943
3944- def test_string_astype_timestamp ():
3944+ def test_string_astype_timestamp (session ):
39453945 pd_series = pd .Series (
39463946 [
39473947 "2014-08-15 08:15:12+00:00" ,
@@ -3950,7 +3950,7 @@ def test_string_astype_timestamp():
39503950 ]
39513951 ).astype (pd .ArrowDtype (pa .string ()))
39523952
3953- bf_series = series .Series (pd_series )
3953+ bf_series = series .Series (pd_series , session = session )
39543954
39553955 pd_result = pd_series .astype (pd .ArrowDtype (pa .timestamp ("us" , tz = "UTC" )))
39563956 bf_result = bf_series .astype (
@@ -3960,13 +3960,14 @@ def test_string_astype_timestamp():
39603960 pd .testing .assert_series_equal (bf_result , pd_result , check_index_type = False )
39613961
39623962
3963- def test_timestamp_astype_string ():
3963+ def test_timestamp_astype_string (session ):
39643964 bf_series = series .Series (
39653965 [
39663966 "2014-08-15 08:15:12+00:00" ,
39673967 "2015-08-15 08:15:12.654754+05:00" ,
39683968 "2016-02-29 00:00:00+08:00" ,
3969- ]
3969+ ],
3970+ session = session ,
39703971 ).astype (pd .ArrowDtype (pa .timestamp ("us" , tz = "UTC" )))
39713972
39723973 expected_result = pd .Series (
@@ -3985,9 +3986,9 @@ def test_timestamp_astype_string():
39853986
39863987
39873988@pytest .mark .parametrize ("errors" , ["raise" , "null" ])
3988- def test_float_astype_json (errors ):
3989+ def test_float_astype_json (errors , session ):
39893990 data = ["1.25" , "2500000000" , None , "-12323.24" ]
3990- bf_series = series .Series (data , dtype = dtypes .FLOAT_DTYPE )
3991+ bf_series = series .Series (data , dtype = dtypes .FLOAT_DTYPE , session = session )
39913992
39923993 bf_result = bf_series .astype (dtypes .JSON_DTYPE , errors = errors )
39933994 assert bf_result .dtype == dtypes .JSON_DTYPE
@@ -3997,9 +3998,9 @@ def test_float_astype_json(errors):
39973998 pd .testing .assert_series_equal (bf_result .to_pandas (), expected_result )
39983999
39994000
4000- def test_float_astype_json_str ():
4001+ def test_float_astype_json_str (session ):
40014002 data = ["1.25" , "2500000000" , None , "-12323.24" ]
4002- bf_series = series .Series (data , dtype = dtypes .FLOAT_DTYPE )
4003+ bf_series = series .Series (data , dtype = dtypes .FLOAT_DTYPE , session = session )
40034004
40044005 bf_result = bf_series .astype ("json" )
40054006 assert bf_result .dtype == dtypes .JSON_DTYPE
@@ -4010,14 +4011,14 @@ def test_float_astype_json_str():
40104011
40114012
40124013@pytest .mark .parametrize ("errors" , ["raise" , "null" ])
4013- def test_string_astype_json (errors ):
4014+ def test_string_astype_json (errors , session ):
40144015 data = [
40154016 "1" ,
40164017 None ,
40174018 '["1","3","5"]' ,
40184019 '{"a":1,"b":["x","y"],"c":{"x":[],"z":false}}' ,
40194020 ]
4020- bf_series = series .Series (data , dtype = dtypes .STRING_DTYPE )
4021+ bf_series = series .Series (data , dtype = dtypes .STRING_DTYPE , session = session )
40214022
40224023 bf_result = bf_series .astype (dtypes .JSON_DTYPE , errors = errors )
40234024 assert bf_result .dtype == dtypes .JSON_DTYPE
@@ -4026,9 +4027,9 @@ def test_string_astype_json(errors):
40264027 pd .testing .assert_series_equal (bf_result .to_pandas (), pd_result )
40274028
40284029
4029- def test_string_astype_json_in_safe_mode ():
4030+ def test_string_astype_json_in_safe_mode (session ):
40304031 data = ["this is not a valid json string" ]
4031- bf_series = series .Series (data , dtype = dtypes .STRING_DTYPE )
4032+ bf_series = series .Series (data , dtype = dtypes .STRING_DTYPE , session = session )
40324033 bf_result = bf_series .astype (dtypes .JSON_DTYPE , errors = "null" )
40334034 assert bf_result .dtype == dtypes .JSON_DTYPE
40344035
@@ -4037,9 +4038,9 @@ def test_string_astype_json_in_safe_mode():
40374038 pd .testing .assert_series_equal (bf_result .to_pandas (), expected )
40384039
40394040
4040- def test_string_astype_json_raise_error ():
4041+ def test_string_astype_json_raise_error (session ):
40414042 data = ["this is not a valid json string" ]
4042- bf_series = series .Series (data , dtype = dtypes .STRING_DTYPE )
4043+ bf_series = series .Series (data , dtype = dtypes .STRING_DTYPE , session = session )
40434044 with pytest .raises (
40444045 google .api_core .exceptions .BadRequest ,
40454046 match = "syntax error while parsing value" ,
@@ -4063,8 +4064,8 @@ def test_string_astype_json_raise_error():
40634064 ),
40644065 ],
40654066)
4066- def test_json_astype_others (data , to_type , errors ):
4067- bf_series = series .Series (data , dtype = dtypes .JSON_DTYPE )
4067+ def test_json_astype_others (data , to_type , errors , session ):
4068+ bf_series = series .Series (data , dtype = dtypes .JSON_DTYPE , session = session )
40684069
40694070 bf_result = bf_series .astype (to_type , errors = errors )
40704071 assert bf_result .dtype == to_type
@@ -4084,8 +4085,8 @@ def test_json_astype_others(data, to_type, errors):
40844085 pytest .param (["true" , None ], dtypes .STRING_DTYPE , id = "to_string" ),
40854086 ],
40864087)
4087- def test_json_astype_others_raise_error (data , to_type ):
4088- bf_series = series .Series (data , dtype = dtypes .JSON_DTYPE )
4088+ def test_json_astype_others_raise_error (data , to_type , session ):
4089+ bf_series = series .Series (data , dtype = dtypes .JSON_DTYPE , session = session )
40894090 with pytest .raises (google .api_core .exceptions .BadRequest ):
40904091 bf_series .astype (to_type , errors = "raise" ).to_pandas ()
40914092
@@ -4099,8 +4100,8 @@ def test_json_astype_others_raise_error(data, to_type):
40994100 pytest .param (["true" , None ], dtypes .STRING_DTYPE , id = "to_string" ),
41004101 ],
41014102)
4102- def test_json_astype_others_in_safe_mode (data , to_type ):
4103- bf_series = series .Series (data , dtype = dtypes .JSON_DTYPE )
4103+ def test_json_astype_others_in_safe_mode (data , to_type , session ):
4104+ bf_series = series .Series (data , dtype = dtypes .JSON_DTYPE , session = session )
41044105 bf_result = bf_series .astype (to_type , errors = "null" )
41054106 assert bf_result .dtype == to_type
41064107
@@ -4414,8 +4415,8 @@ def test_query_job_setters(scalars_dfs):
44144415 ([1 , 1 , 1 , 1 , 1 ],),
44154416 ],
44164417)
4417- def test_is_monotonic_increasing (series_input ):
4418- scalars_df = series .Series (series_input , dtype = pd .Int64Dtype ())
4418+ def test_is_monotonic_increasing (series_input , session ):
4419+ scalars_df = series .Series (series_input , dtype = pd .Int64Dtype (), session = session )
44194420 scalars_pandas_df = pd .Series (series_input , dtype = pd .Int64Dtype ())
44204421 assert (
44214422 scalars_df .is_monotonic_increasing == scalars_pandas_df .is_monotonic_increasing
@@ -4433,8 +4434,8 @@ def test_is_monotonic_increasing(series_input):
44334434 ([1 , 1 , 1 , 1 , 1 ],),
44344435 ],
44354436)
4436- def test_is_monotonic_decreasing (series_input ):
4437- scalars_df = series .Series (series_input )
4437+ def test_is_monotonic_decreasing (series_input , session ):
4438+ scalars_df = series .Series (series_input , session = session )
44384439 scalars_pandas_df = pd .Series (series_input )
44394440 assert (
44404441 scalars_df .is_monotonic_decreasing == scalars_pandas_df .is_monotonic_decreasing
0 commit comments