Don't hide import errors when importing plugins and provide an easy to debug message. See #375 and #1998.
(
pytester: Pytester, pytestpm: PytestPluginManager
)
| 236 | |
| 237 | |
| 238 | def test_importplugin_error_message( |
| 239 | pytester: Pytester, pytestpm: PytestPluginManager |
| 240 | ) -> None: |
| 241 | """Don't hide import errors when importing plugins and provide |
| 242 | an easy to debug message. |
| 243 | |
| 244 | See #375 and #1998. |
| 245 | """ |
| 246 | pytester.syspathinsert(pytester.path) |
| 247 | pytester.makepyfile( |
| 248 | qwe="""\ |
| 249 | def test_traceback(): |
| 250 | raise ImportError('Not possible to import: ☺') |
| 251 | test_traceback() |
| 252 | """ |
| 253 | ) |
| 254 | with pytest.raises(ImportError) as excinfo: |
| 255 | pytestpm.import_plugin("qwe") |
| 256 | |
| 257 | assert str(excinfo.value).endswith( |
| 258 | 'Error importing plugin "qwe": Not possible to import: ☺' |
| 259 | ) |
| 260 | assert "in test_traceback" in str(excinfo.traceback[-1]) |
| 261 | |
| 262 | |
| 263 | class TestPytestPluginManager: |
nothing calls this directly
no test coverage detected