diff --git a/pandas/tests/frame/methods/test_astype.py b/pandas/tests/frame/methods/test_astype.py index eb1ee4e7b2970..ea9c33c31bdcf 100644 --- a/pandas/tests/frame/methods/test_astype.py +++ b/pandas/tests/frame/methods/test_astype.py @@ -3,8 +3,6 @@ import numpy as np import pytest -from pandas._config import using_string_dtype - import pandas.util._test_decorators as td import pandas as pd @@ -745,9 +743,11 @@ def test_astype_tz_object_conversion(self, tz): result = result.astype({"tz": "datetime64[ns, Europe/London]"}) tm.assert_frame_equal(result, expected) - @pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) GH#60639") def test_astype_dt64_to_string( - self, frame_or_series, tz_naive_fixture, using_infer_string + self, + frame_or_series, + tz_naive_fixture, + string_dtype_no_object, ): # GH#41409 tz = tz_naive_fixture @@ -757,23 +757,17 @@ def test_astype_dt64_to_string( dta[0] = NaT obj = frame_or_series(dta) - result = obj.astype("string") + result = obj.astype(string_dtype_no_object) # Check that Series/DataFrame.astype matches DatetimeArray.astype - expected = frame_or_series(dta.astype("string")) + expected = frame_or_series(dta.astype(string_dtype_no_object)) tm.assert_equal(result, expected) item = result.iloc[0] if frame_or_series is DataFrame: item = item.iloc[0] - if using_infer_string: - assert item is np.nan - else: - assert item is pd.NA - # For non-NA values, we should match what we get for non-EA str - alt = obj.astype(str) - assert np.all(alt.iloc[1:] == result.iloc[1:]) + assert item is string_dtype_no_object.na_value def test_astype_td64_to_string(self, frame_or_series): # GH#41409