MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_importplugin_error_message

Function test_importplugin_error_message

testing/test_pluginmanager.py:190–212  ·  view source on GitHub ↗

Don't hide import errors when importing plugins and provide an easy to debug message. See #375 and #1998.

(
    pytester: Pytester, pytestpm: PytestPluginManager
)

Source from the content-addressed store, hash-verified

188
189
190def test_importplugin_error_message(
191 pytester: Pytester, pytestpm: PytestPluginManager
192) -> None:
193 """Don't hide import errors when importing plugins and provide
194 an easy to debug message.
195
196 See #375 and #1998.
197 """
198 pytester.syspathinsert(pytester.path)
199 pytester.makepyfile(
200 qwe="""\
201 def test_traceback():
202 raise ImportError('Not possible to import: ☺')
203 test_traceback()
204 """
205 )
206 with pytest.raises(ImportError) as excinfo:
207 pytestpm.import_plugin("qwe")
208
209 assert str(excinfo.value).endswith(
210 'Error importing plugin "qwe": Not possible to import: ☺'
211 )
212 assert "in test_traceback" in str(excinfo.traceback[-1])
213
214
215class TestPytestPluginManager:

Callers

nothing calls this directly

Calls 3

import_pluginMethod · 0.80
syspathinsertMethod · 0.45
makepyfileMethod · 0.45

Tested by

no test coverage detected