Skip to content

Commit b8beead

Browse files
committed
Use string_dtype_no_object fixture
1 parent 572d62c commit b8beead

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

pandas/tests/frame/methods/test_astype.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,10 @@ def test_astype_tz_object_conversion(self, tz):
744744
tm.assert_frame_equal(result, expected)
745745

746746
def test_astype_dt64_to_string(
747-
self, frame_or_series, tz_naive_fixture, using_infer_string
747+
self,
748+
frame_or_series,
749+
tz_naive_fixture,
750+
string_dtype_no_object,
748751
):
749752
# GH#41409
750753
tz = tz_naive_fixture
@@ -754,28 +757,17 @@ def test_astype_dt64_to_string(
754757
dta[0] = NaT
755758

756759
obj = frame_or_series(dta)
757-
result = obj.astype("string")
760+
result = obj.astype(string_dtype_no_object)
758761

759762
# Check that Series/DataFrame.astype matches DatetimeArray.astype
760-
expected = frame_or_series(dta.astype("string"))
763+
expected = frame_or_series(dta.astype(string_dtype_no_object))
761764
tm.assert_equal(result, expected)
762765

763766
item = result.iloc[0]
764767
if frame_or_series is DataFrame:
765768
item = item.iloc[0]
766769

767-
assert item is pd.NA
768-
769-
# Check that Series/DataFrame.astype matches DatetimeArray.astype
770-
result = obj.astype("str")
771-
expected = frame_or_series(dta.astype("str"))
772-
tm.assert_equal(result, expected)
773-
774-
item = result.iloc[0]
775-
if frame_or_series is DataFrame:
776-
item = item.iloc[0]
777-
if using_infer_string:
778-
assert item is np.nan
770+
assert item is string_dtype_no_object.na_value
779771

780772
def test_astype_td64_to_string(self, frame_or_series):
781773
# GH#41409

0 commit comments

Comments
 (0)