@@ -137,12 +137,12 @@ def test_foo(pytestconfig):
137137 def test_pytest_plugins_rewrite_module_names_correctly (self , testdir ):
138138 """Test that we match files correctly when they are marked for rewriting (#2939)."""
139139 contents = {
140- "conftest.py" : """
140+ "conftest.py" : """\
141141 pytest_plugins = "ham"
142142 """ ,
143143 "ham.py" : "" ,
144144 "hamster.py" : "" ,
145- "test_foo.py" : """
145+ "test_foo.py" : """\
146146 def test_foo(pytestconfig):
147147 assert pytestconfig.pluginmanager.rewrite_hook.find_module('ham') is not None
148148 assert pytestconfig.pluginmanager.rewrite_hook.find_module('hamster') is None
@@ -153,14 +153,13 @@ def test_foo(pytestconfig):
153153 assert result .ret == 0
154154
155155 @pytest .mark .parametrize ("mode" , ["plain" , "rewrite" ])
156- @pytest .mark .parametrize ("plugin_state" , ["development" , "installed" ])
157- def test_installed_plugin_rewrite (self , testdir , mode , plugin_state , monkeypatch ):
156+ def test_installed_plugin_rewrite (self , testdir , mode , monkeypatch ):
158157 monkeypatch .delenv ("PYTEST_DISABLE_PLUGIN_AUTOLOAD" , raising = False )
159158 # Make sure the hook is installed early enough so that plugins
160159 # installed via setuptools are rewritten.
161160 testdir .tmpdir .join ("hampkg" ).ensure (dir = 1 )
162161 contents = {
163- "hampkg/__init__.py" : """
162+ "hampkg/__init__.py" : """\
164163 import pytest
165164
166165 @pytest.fixture
@@ -169,7 +168,7 @@ def check(values, value):
169168 assert values.pop(0) == value
170169 return check
171170 """ ,
172- "spamplugin.py" : """
171+ "spamplugin.py" : """\
173172 import pytest
174173 from hampkg import check_first2
175174
@@ -179,46 +178,31 @@ def check(values, value):
179178 assert values.pop(0) == value
180179 return check
181180 """ ,
182- "mainwrapper.py" : """
183- import pytest, pkg_resources
184-
185- plugin_state = "{plugin_state}"
186-
187- class DummyDistInfo(object):
188- project_name = 'spam'
189- version = '1.0'
190-
191- def _get_metadata(self, name):
192- # 'RECORD' meta-data only available in installed plugins
193- if name == 'RECORD' and plugin_state == "installed":
194- return ['spamplugin.py,sha256=abc,123',
195- 'hampkg/__init__.py,sha256=abc,123']
196- # 'SOURCES.txt' meta-data only available for plugins in development mode
197- elif name == 'SOURCES.txt' and plugin_state == "development":
198- return ['spamplugin.py',
199- 'hampkg/__init__.py']
200- return []
181+ "mainwrapper.py" : """\
182+ import pytest, importlib_metadata
201183
202184 class DummyEntryPoint(object):
203185 name = 'spam'
204186 module_name = 'spam.py'
205- attrs = ()
206- extras = None
207- dist = DummyDistInfo()
187+ group = 'pytest11'
208188
209- def load(self, require=True, *args, **kwargs ):
189+ def load(self):
210190 import spamplugin
211191 return spamplugin
212192
213- def iter_entry_points(group, name=None):
214- yield DummyEntryPoint()
193+ class DummyDistInfo(object):
194+ version = '1.0'
195+ files = ('spamplugin.py', 'hampkg/__init__.py')
196+ entry_points = (DummyEntryPoint(),)
197+ metadata = {'name': 'foo'}
215198
216- pkg_resources.iter_entry_points = iter_entry_points
199+ def distributions():
200+ return (DummyDistInfo(),)
201+
202+ importlib_metadata.distributions = distributions
217203 pytest.main()
218- """ .format (
219- plugin_state = plugin_state
220- ),
221- "test_foo.py" : """
204+ """ ,
205+ "test_foo.py" : """\
222206 def test(check_first):
223207 check_first([10, 30], 30)
224208
0 commit comments