@@ -92,7 +92,7 @@ def test__maybe_finalize(self, *, map):
9292
9393 def test__finalize (self , * , map ):
9494 map .namespaces = {"foo" }
95- with patch_iter_entry_points ():
95+ with patch_importlib_metadata_entry_points ():
9696 map ._finalize ()
9797 assert map .aliases ["ep1" ] == "foo:a"
9898 assert map .aliases ["ep2" ] == "bar:c"
@@ -158,7 +158,7 @@ def test_smart_import():
158158
159159
160160def test_load_extension_classes ():
161- with patch_iter_entry_points ():
161+ with patch_importlib_metadata_entry_points ():
162162 with patch ("mode.utils.imports.symbol_by_name" ) as sbn :
163163 assert list (load_extension_classes ("foo" )) == [
164164 EntrypointExtension ("ep1" , sbn .return_value ),
@@ -169,33 +169,37 @@ def test_load_extension_classes():
169169
170170
171171def test_load_extension_classes_syntax_error ():
172- with patch_iter_entry_points ():
172+ with patch_importlib_metadata_entry_points ():
173173 with patch ("mode.utils.imports.symbol_by_name" ) as sbn :
174174 sbn .side_effect = SyntaxError ()
175175 with pytest .warns (UserWarning ):
176176 assert list (load_extension_classes ("foo" )) == []
177177
178178
179179def test_load_extension_class_names ():
180- with patch_iter_entry_points ():
180+ with patch_importlib_metadata_entry_points ():
181181 assert list (load_extension_class_names ("foo" )) == [
182182 RawEntrypointExtension ("ep1" , "foo:a" ),
183183 RawEntrypointExtension ("ep2" , "bar:c" ),
184184 ]
185185
186186
187187@contextmanager
188- def patch_iter_entry_points ():
189- with patch ("pkg_resources.iter_entry_points" ) as iter_entry_points :
188+ def patch_importlib_metadata_entry_points ():
189+ with patch (
190+ "importlib.metadata.entry_points"
191+ ) as importlib_metadata_entry_points :
190192 ep1 = Mock (name = "ep1" )
191193 ep1 .name = "ep1"
192- ep1 .module_name = "foo"
193- ep1 .attrs = [ "a" , "b" ]
194+ ep1 .module = "foo"
195+ ep1 .attr = "a"
194196 ep2 = Mock (name = "ep2" )
195197 ep2 .name = "ep2"
196- ep2 .module_name = "bar"
197- ep2 .attrs = ["c" , "d" ]
198- iter_entry_points .return_value = [ep1 , ep2 ]
198+ ep2 .module = "bar"
199+ ep2 .attr = "c"
200+ mock_entry_points = Mock ()
201+ mock_entry_points .select .return_value = [ep1 , ep2 ]
202+ importlib_metadata_entry_points .return_value = mock_entry_points
199203 yield
200204
201205
0 commit comments