@@ -891,20 +891,24 @@ def test_concat_same_type_different_freq(self, unit):
891891
892892 tm .assert_datetime_array_equal (result , expected )
893893
894- def test_strftime (self , arr1d ):
894+ def test_strftime (self , arr1d , using_infer_string ):
895895 arr = arr1d
896896
897897 result = arr .strftime ("%Y %b" )
898898 expected = np .array ([ts .strftime ("%Y %b" ) for ts in arr ], dtype = object )
899- tm .assert_numpy_array_equal (result , expected )
899+ if using_infer_string :
900+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
901+ tm .assert_equal (result , expected )
900902
901- def test_strftime_nat (self ):
903+ def test_strftime_nat (self , using_infer_string ):
902904 # GH 29578
903905 arr = DatetimeIndex (["2019-01-01" , NaT ])._data
904906
905907 result = arr .strftime ("%Y-%m-%d" )
906908 expected = np .array (["2019-01-01" , np .nan ], dtype = object )
907- tm .assert_numpy_array_equal (result , expected )
909+ if using_infer_string :
910+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
911+ tm .assert_equal (result , expected )
908912
909913
910914class TestTimedeltaArray (SharedTests ):
@@ -1161,20 +1165,24 @@ def test_array_interface(self, arr1d):
11611165 expected = np .asarray (arr ).astype ("S20" )
11621166 tm .assert_numpy_array_equal (result , expected )
11631167
1164- def test_strftime (self , arr1d ):
1168+ def test_strftime (self , arr1d , using_infer_string ):
11651169 arr = arr1d
11661170
11671171 result = arr .strftime ("%Y" )
11681172 expected = np .array ([per .strftime ("%Y" ) for per in arr ], dtype = object )
1169- tm .assert_numpy_array_equal (result , expected )
1173+ if using_infer_string :
1174+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
1175+ tm .assert_equal (result , expected )
11701176
1171- def test_strftime_nat (self ):
1177+ def test_strftime_nat (self , using_infer_string ):
11721178 # GH 29578
11731179 arr = PeriodArray (PeriodIndex (["2019-01-01" , NaT ], dtype = "period[D]" ))
11741180
11751181 result = arr .strftime ("%Y-%m-%d" )
11761182 expected = np .array (["2019-01-01" , np .nan ], dtype = object )
1177- tm .assert_numpy_array_equal (result , expected )
1183+ if using_infer_string :
1184+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
1185+ tm .assert_equal (result , expected )
11781186
11791187
11801188@pytest .mark .parametrize (
0 commit comments