7
7
8
8
from pandas .compat import HAS_PYARROW
9
9
from pandas .compat .pyarrow import pa_version_under12p0
10
- import pandas .util ._test_decorators as td
11
10
12
11
from pandas import (
13
12
DataFrame ,
@@ -111,7 +110,8 @@ def test_astype_string_and_object_update_original(dtype, new_dtype):
111
110
tm .assert_frame_equal (df2 , df_orig )
112
111
113
112
114
- def test_astype_string_copy_on_pickle_roundrip ():
113
+ def test_astype_str_copy_on_pickle_roundrip ():
114
+ # TODO(infer_string) this test can be removed after 3.0 (once str is the default)
115
115
# https://github.com/pandas-dev/pandas/issues/54654
116
116
# ensure_string_array may alter array inplace
117
117
base = Series (np .array ([(1 , 2 ), None , 1 ], dtype = "object" ))
@@ -120,14 +120,22 @@ def test_astype_string_copy_on_pickle_roundrip():
120
120
tm .assert_series_equal (base , base_copy )
121
121
122
122
123
- @td .skip_if_no ("pyarrow" )
124
- def test_astype_string_read_only_on_pickle_roundrip ():
123
+ def test_astype_string_copy_on_pickle_roundrip (any_string_dtype ):
124
+ # https://github.com/pandas-dev/pandas/issues/54654
125
+ # ensure_string_array may alter array inplace
126
+ base = Series (np .array ([(1 , 2 ), None , 1 ], dtype = "object" ))
127
+ base_copy = pickle .loads (pickle .dumps (base ))
128
+ base_copy .astype (any_string_dtype )
129
+ tm .assert_series_equal (base , base_copy )
130
+
131
+
132
+ def test_astype_string_read_only_on_pickle_roundrip (any_string_dtype ):
125
133
# https://github.com/pandas-dev/pandas/issues/54654
126
134
# ensure_string_array may alter read-only array inplace
127
135
base = Series (np .array ([(1 , 2 ), None , 1 ], dtype = "object" ))
128
136
base_copy = pickle .loads (pickle .dumps (base ))
129
137
base_copy ._values .flags .writeable = False
130
- base_copy .astype ("string[pyarrow]" )
138
+ base_copy .astype (any_string_dtype )
131
139
tm .assert_series_equal (base , base_copy )
132
140
133
141
0 commit comments