@@ -137,12 +137,12 @@ def test_foo(pytestconfig):
137
137
def test_pytest_plugins_rewrite_module_names_correctly (self , testdir ):
138
138
"""Test that we match files correctly when they are marked for rewriting (#2939)."""
139
139
contents = {
140
- "conftest.py" : """
140
+ "conftest.py" : """\
141
141
pytest_plugins = "ham"
142
142
""" ,
143
143
"ham.py" : "" ,
144
144
"hamster.py" : "" ,
145
- "test_foo.py" : """
145
+ "test_foo.py" : """\
146
146
def test_foo(pytestconfig):
147
147
assert pytestconfig.pluginmanager.rewrite_hook.find_module('ham') is not None
148
148
assert pytestconfig.pluginmanager.rewrite_hook.find_module('hamster') is None
@@ -153,14 +153,13 @@ def test_foo(pytestconfig):
153
153
assert result .ret == 0
154
154
155
155
@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 ):
158
157
monkeypatch .delenv ("PYTEST_DISABLE_PLUGIN_AUTOLOAD" , raising = False )
159
158
# Make sure the hook is installed early enough so that plugins
160
159
# installed via setuptools are rewritten.
161
160
testdir .tmpdir .join ("hampkg" ).ensure (dir = 1 )
162
161
contents = {
163
- "hampkg/__init__.py" : """
162
+ "hampkg/__init__.py" : """\
164
163
import pytest
165
164
166
165
@pytest.fixture
@@ -169,7 +168,7 @@ def check(values, value):
169
168
assert values.pop(0) == value
170
169
return check
171
170
""" ,
172
- "spamplugin.py" : """
171
+ "spamplugin.py" : """\
173
172
import pytest
174
173
from hampkg import check_first2
175
174
@@ -179,46 +178,31 @@ def check(values, value):
179
178
assert values.pop(0) == value
180
179
return check
181
180
""" ,
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
201
183
202
184
class DummyEntryPoint(object):
203
185
name = 'spam'
204
186
module_name = 'spam.py'
205
- attrs = ()
206
- extras = None
207
- dist = DummyDistInfo()
187
+ group = 'pytest11'
208
188
209
- def load(self, require=True, *args, **kwargs ):
189
+ def load(self):
210
190
import spamplugin
211
191
return spamplugin
212
192
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'}
215
198
216
- pkg_resources.iter_entry_points = iter_entry_points
199
+ def distributions():
200
+ return (DummyDistInfo(),)
201
+
202
+ importlib_metadata.distributions = distributions
217
203
pytest.main()
218
- """ .format (
219
- plugin_state = plugin_state
220
- ),
221
- "test_foo.py" : """
204
+ """ ,
205
+ "test_foo.py" : """\
222
206
def test(check_first):
223
207
check_first([10, 30], 30)
224
208
0 commit comments