22import pytest
33
44import pandas as pd
5+ from pandas .api .extensions import ExtensionArray
56from pandas .core .internals import ExtensionBlock
67from pandas .tests .extension .base .base import BaseExtensionTests
78
@@ -24,13 +25,15 @@ def test_series_constructor(self, data):
2425 result = pd .Series (data )
2526 assert result .dtype == data .dtype
2627 assert len (result ) == len (data )
27- assert isinstance (result ._mgr .blocks [0 ], ExtensionBlock )
28- assert result ._mgr .blocks [0 ].values is data
28+ if hasattr (result ._mgr , "blocks" ):
29+ assert isinstance (result ._mgr .blocks [0 ], ExtensionBlock )
30+ assert result ._mgr .array is data
2931
3032 # Series[EA] is unboxed / boxed correctly
3133 result2 = pd .Series (result )
3234 assert result2 .dtype == data .dtype
33- assert isinstance (result2 ._mgr .blocks [0 ], ExtensionBlock )
35+ if hasattr (result ._mgr , "blocks" ):
36+ assert isinstance (result2 ._mgr .blocks [0 ], ExtensionBlock )
3437
3538 def test_series_constructor_no_data_with_index (self , dtype , na_value ):
3639 result = pd .Series (index = [1 , 2 , 3 ], dtype = dtype )
@@ -64,13 +67,17 @@ def test_dataframe_constructor_from_dict(self, data, from_series):
6467 result = pd .DataFrame ({"A" : data })
6568 assert result .dtypes ["A" ] == data .dtype
6669 assert result .shape == (len (data ), 1 )
67- assert isinstance (result ._mgr .blocks [0 ], ExtensionBlock )
70+ if hasattr (result ._mgr , "blocks" ):
71+ assert isinstance (result ._mgr .blocks [0 ], ExtensionBlock )
72+ assert isinstance (result ._mgr .arrays [0 ], ExtensionArray )
6873
6974 def test_dataframe_from_series (self , data ):
7075 result = pd .DataFrame (pd .Series (data ))
7176 assert result .dtypes [0 ] == data .dtype
7277 assert result .shape == (len (data ), 1 )
73- assert isinstance (result ._mgr .blocks [0 ], ExtensionBlock )
78+ if hasattr (result ._mgr , "blocks" ):
79+ assert isinstance (result ._mgr .blocks [0 ], ExtensionBlock )
80+ assert isinstance (result ._mgr .arrays [0 ], ExtensionArray )
7481
7582 def test_series_given_mismatched_index_raises (self , data ):
7683 msg = r"Length of values \(3\) does not match length of index \(5\)"
0 commit comments