77from unittest .mock import Mock , call , patch
88
99import pytest
10- from pkg_resources import Distribution , EntryPoint
10+ from importlib . metadata import Distribution , EntryPoint
1111
1212from mlblocks import discovery
1313
@@ -59,7 +59,7 @@ def test_add_pipelines_path():
5959
6060
6161@patch ('mlblocks.discovery._PRIMITIVES_PATHS' , new = ['a' , 'b' ])
62- @patch ('mlblocks.discovery.pkg_resources.iter_entry_points ' )
62+ @patch ('mlblocks.discovery.importlib.metadata.entry_points ' )
6363def test__load_entry_points_no_entry_points (iep_mock ):
6464 # setup
6565 iep_mock .return_value == []
@@ -70,26 +70,28 @@ def test__load_entry_points_no_entry_points(iep_mock):
7070 # assert
7171 assert paths == []
7272 expected_calls = [
73- call ('mlprimitives' ),
73+ call (group = 'mlprimitives' ),
7474 ]
7575 assert iep_mock .call_args_list == expected_calls
7676
7777
78- @patch ('mlblocks.discovery.pkg_resources.iter_entry_points ' )
78+ @patch ('mlblocks.discovery.importlib.metadata.entry_points ' )
7979def test__load_entry_points_entry_points (iep_mock ):
8080 # setup
81- something_else_ep = EntryPoint ('something_else' , 'mlblocks.__version__' )
81+ something_else_ep = EntryPoint (
82+ name = 'something_else' ,
83+ value = 'mlblocks.__version__' ,
84+ group = 'mlblocks'
85+ )
8286 primitives_ep = EntryPoint (
83- 'primitives' ,
84- 'tests.test_discovery' ,
85- attrs = ['FAKE_PRIMITIVES_PATH' ],
86- dist = Distribution ()
87+ name = 'primitives' ,
88+ value = 'tests.test_discovery:FAKE_PRIMITIVES_PATH' ,
89+ group = 'mlblocks'
8790 )
8891 another_primitives_ep = EntryPoint (
89- 'primitives' ,
90- 'tests.test_discovery' ,
91- attrs = ['FAKE_PRIMITIVES_PATHS' ],
92- dist = Distribution ()
92+ name = 'primitives' ,
93+ value = 'tests.test_discovery:FAKE_PRIMITIVES_PATHS' ,
94+ group = 'mlblocks'
9395 )
9496 iep_mock .return_value = [
9597 something_else_ep ,
@@ -109,7 +111,7 @@ def test__load_entry_points_entry_points(iep_mock):
109111 assert paths == expected
110112
111113 expected_calls = [
112- call ('mlblocks' ),
114+ call (group = 'mlblocks' ),
113115 ]
114116 assert iep_mock .call_args_list == expected_calls
115117
0 commit comments