@@ -889,20 +889,24 @@ def test_concat_same_type_different_freq(self, unit):
889889
890890 tm .assert_datetime_array_equal (result , expected )
891891
892- def test_strftime (self , arr1d ):
892+ def test_strftime (self , arr1d , using_infer_string ):
893893 arr = arr1d
894894
895895 result = arr .strftime ("%Y %b" )
896896 expected = np .array ([ts .strftime ("%Y %b" ) for ts in arr ], dtype = object )
897- tm .assert_numpy_array_equal (result , expected )
897+ if using_infer_string :
898+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
899+ tm .assert_equal (result , expected )
898900
899- def test_strftime_nat (self ):
901+ def test_strftime_nat (self , using_infer_string ):
900902 # GH 29578
901903 arr = DatetimeIndex (["2019-01-01" , NaT ])._data
902904
903905 result = arr .strftime ("%Y-%m-%d" )
904906 expected = np .array (["2019-01-01" , np .nan ], dtype = object )
905- tm .assert_numpy_array_equal (result , expected )
907+ if using_infer_string :
908+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
909+ tm .assert_equal (result , expected )
906910
907911
908912class TestTimedeltaArray (SharedTests ):
@@ -1159,20 +1163,24 @@ def test_array_interface(self, arr1d):
11591163 expected = np .asarray (arr ).astype ("S20" )
11601164 tm .assert_numpy_array_equal (result , expected )
11611165
1162- def test_strftime (self , arr1d ):
1166+ def test_strftime (self , arr1d , using_infer_string ):
11631167 arr = arr1d
11641168
11651169 result = arr .strftime ("%Y" )
11661170 expected = np .array ([per .strftime ("%Y" ) for per in arr ], dtype = object )
1167- tm .assert_numpy_array_equal (result , expected )
1171+ if using_infer_string :
1172+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
1173+ tm .assert_equal (result , expected )
11681174
1169- def test_strftime_nat (self ):
1175+ def test_strftime_nat (self , using_infer_string ):
11701176 # GH 29578
11711177 arr = PeriodArray (PeriodIndex (["2019-01-01" , NaT ], dtype = "period[D]" ))
11721178
11731179 result = arr .strftime ("%Y-%m-%d" )
11741180 expected = np .array (["2019-01-01" , np .nan ], dtype = object )
1175- tm .assert_numpy_array_equal (result , expected )
1181+ if using_infer_string :
1182+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
1183+ tm .assert_equal (result , expected )
11761184
11771185
11781186@pytest .mark .parametrize (
0 commit comments