@@ -687,7 +687,7 @@ def test_loc_setitem_fullindex_views(self):
687
687
df .loc [df .index ] = df .loc [df .index ]
688
688
tm .assert_frame_equal (df , df2 )
689
689
690
- def test_rhs_alignment (self ):
690
+ def test_rhs_alignment (self , using_infer_string ):
691
691
# GH8258, tests that both rows & columns are aligned to what is
692
692
# assigned to. covers both uniform data-type & multi-type cases
693
693
def run_tests (df , rhs , right_loc , right_iloc ):
@@ -731,8 +731,17 @@ def run_tests(df, rhs, right_loc, right_iloc):
731
731
frame ["jolie" ] = frame ["jolie" ].map (lambda x : f"@{ x } " )
732
732
right_iloc ["joe" ] = [1.0 , "@-28" , "@-20" , "@-12" , 17.0 ]
733
733
right_iloc ["jolie" ] = ["@2" , - 26.0 , - 18.0 , - 10.0 , "@18" ]
734
- with tm .assert_produces_warning (FutureWarning , match = "incompatible dtype" ):
735
- run_tests (df , rhs , right_loc , right_iloc )
734
+ if using_infer_string :
735
+ with pytest .raises (
736
+ TypeError , match = "Must provide strings|Scalar must be NA or str"
737
+ ):
738
+ with tm .assert_produces_warning (
739
+ FutureWarning , match = "incompatible dtype"
740
+ ):
741
+ run_tests (df , rhs , right_loc , right_iloc )
742
+ else :
743
+ with tm .assert_produces_warning (FutureWarning , match = "incompatible dtype" ):
744
+ run_tests (df , rhs , right_loc , right_iloc )
736
745
737
746
@pytest .mark .parametrize (
738
747
"idx" , [_mklbl ("A" , 20 ), np .arange (20 ) + 100 , np .linspace (100 , 150 , 20 )]
0 commit comments