1
1
import numpy as np
2
2
import pytest
3
3
4
+ import pandas .util ._test_decorators as td
5
+
4
6
import pandas as pd
5
7
import pandas ._testing as tm
6
8
@@ -9,7 +11,16 @@ class TestConvertDtypes:
9
11
@pytest .mark .parametrize (
10
12
"convert_integer, expected" , [(False , np .dtype ("int32" )), (True , "Int32" )]
11
13
)
12
- def test_convert_dtypes (self , convert_integer , expected ):
14
+ @pytest .mark .parametrize (
15
+ "string_storage" ,
16
+ [
17
+ "python" ,
18
+ pytest .param (
19
+ "pyarrow" , marks = td .skip_if_no ("pyarrow" , min_version = "1.0.0" )
20
+ ),
21
+ ],
22
+ )
23
+ def test_convert_dtypes (self , convert_integer , expected , string_storage ):
13
24
# Specific types are tested in tests/series/test_dtypes.py
14
25
# Just check that it works for DataFrame here
15
26
df = pd .DataFrame (
@@ -18,11 +29,12 @@ def test_convert_dtypes(self, convert_integer, expected):
18
29
"b" : pd .Series (["x" , "y" , "z" ], dtype = np .dtype ("O" )),
19
30
}
20
31
)
21
- result = df .convert_dtypes (True , True , convert_integer , False )
32
+ with pd .option_context ("string_storage" , string_storage ):
33
+ result = df .convert_dtypes (True , True , convert_integer , False )
22
34
expected = pd .DataFrame (
23
35
{
24
36
"a" : pd .Series ([1 , 2 , 3 ], dtype = expected ),
25
- "b" : pd .Series (["x" , "y" , "z" ], dtype = "string" ),
37
+ "b" : pd .Series (["x" , "y" , "z" ], dtype = f "string[ { string_storage } ] " ),
26
38
}
27
39
)
28
40
tm .assert_frame_equal (result , expected )
0 commit comments