1
1
import pandas as pd
2
2
import pandas ._testing as tm
3
- from pandas .core .accessor import DataFrameAccessorLoader
3
+ from pandas .core .accessor import AccessorEntryPointLoader
4
4
5
5
6
6
def test_no_accessors (monkeypatch ):
@@ -13,7 +13,7 @@ def mock_entry_points(*, group):
13
13
# Patch entry_points in the correct module
14
14
monkeypatch .setattr ("pandas.core.accessor.entry_points" , mock_entry_points )
15
15
16
- DataFrameAccessorLoader .load ()
16
+ AccessorEntryPointLoader .load ()
17
17
18
18
19
19
def test_load_dataframe_accessors (monkeypatch ):
@@ -34,14 +34,14 @@ def test_method(self):
34
34
35
35
# Mock entry_points
36
36
def mock_entry_points (* , group ):
37
- if group == DataFrameAccessorLoader .ENTRY_POINT_GROUP :
37
+ if group == AccessorEntryPointLoader .ENTRY_POINT_GROUP :
38
38
return [MockEntryPoint ()]
39
39
return []
40
40
41
41
# Patch entry_points in the correct module
42
42
monkeypatch .setattr ("pandas.core.accessor.entry_points" , mock_entry_points )
43
43
44
- DataFrameAccessorLoader .load ()
44
+ AccessorEntryPointLoader .load ()
45
45
46
46
# Create DataFrame and verify that the accessor was registered
47
47
df = pd .DataFrame ({"a" : [1 , 2 , 3 ]})
@@ -80,18 +80,18 @@ def which(self):
80
80
return Accessor2
81
81
82
82
def mock_entry_points (* , group ):
83
- if group == DataFrameAccessorLoader .ENTRY_POINT_GROUP :
83
+ if group == AccessorEntryPointLoader .ENTRY_POINT_GROUP :
84
84
return [MockEntryPoint1 (), MockEntryPoint2 ()]
85
85
return []
86
86
87
87
monkeypatch .setattr ("pandas.core.accessor.entry_points" , mock_entry_points )
88
88
89
89
# Check that the UserWarning is raised
90
90
with tm .assert_produces_warning (UserWarning , match = "duplicate_accessor" ) as record :
91
- DataFrameAccessorLoader .load ()
91
+ AccessorEntryPointLoader .load ()
92
92
93
93
messages = [str (w .message ) for w in record ]
94
- assert any ("two packages with the same name" in msg for msg in messages )
94
+ assert any ("you have two packages with the same name: " in msg for msg in messages )
95
95
96
96
df = pd .DataFrame ({"x" : [1 , 2 , 3 ]})
97
97
assert hasattr (df , "duplicate_accessor" )
@@ -129,15 +129,15 @@ def which(self):
129
129
return Accessor2
130
130
131
131
def mock_entry_points (* , group ):
132
- if group == DataFrameAccessorLoader .ENTRY_POINT_GROUP :
132
+ if group == AccessorEntryPointLoader .ENTRY_POINT_GROUP :
133
133
return [MockEntryPoint1 (), MockEntryPoint2 ()]
134
134
return []
135
135
136
136
monkeypatch .setattr ("pandas.core.accessor.entry_points" , mock_entry_points )
137
137
138
138
# Check that no UserWarning is raised
139
139
with tm .assert_produces_warning (None , check_stacklevel = False ):
140
- DataFrameAccessorLoader .load ()
140
+ AccessorEntryPointLoader .load ()
141
141
142
142
df = pd .DataFrame ({"x" : [1 , 2 , 3 ]})
143
143
assert hasattr (df , "accessor1" ), "Accessor1 not registered"
@@ -191,15 +191,15 @@ def which(self):
191
191
return Accessor3
192
192
193
193
def mock_entry_points (* , group ):
194
- if group == DataFrameAccessorLoader .ENTRY_POINT_GROUP :
194
+ if group == AccessorEntryPointLoader .ENTRY_POINT_GROUP :
195
195
return [MockEntryPoint1 (), MockEntryPoint2 (), MockEntryPoint3 ()]
196
196
return []
197
197
198
198
monkeypatch .setattr ("pandas.core.accessor.entry_points" , mock_entry_points )
199
199
200
200
# Capture warnings
201
201
with tm .assert_produces_warning (UserWarning , match = "duplicate_accessor" ) as record :
202
- DataFrameAccessorLoader .load ()
202
+ AccessorEntryPointLoader .load ()
203
203
204
204
messages = [str (w .message ) for w in record ]
205
205
0 commit comments