diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2016-10-12 17:46:47 -0300 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2016-10-12 18:19:32 -0300 |
commit | 78eec0d7f8bf177a368575271483ca575c11ad92 (patch) | |
tree | 6e83854f9842bf96034bef0428e016a972e21fc7 /testing | |
parent | 3301a1c17379b6e721734bbc25040db4ff4bc956 (diff) | |
download | pytest-78eec0d7f8bf177a368575271483ca575c11ad92.tar.gz |
Handle import errors with non-ascii messages when importing plugins
Fix #1998
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test_pluginmanager.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 36847638d..e61c84247 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -1,3 +1,4 @@ +# encoding: UTF-8 import pytest import py import os @@ -179,15 +180,20 @@ def test_default_markers(testdir): ]) -def test_importplugin_issue375(testdir, pytestpm): +def test_importplugin_error_message(testdir, pytestpm): """Don't hide import errors when importing plugins and provide an easy to debug message. + + See #375 and #1998. """ testdir.syspathinsert(testdir.tmpdir) - testdir.makepyfile(qwe="import aaaa") + testdir.makepyfile(qwe=""" + # encoding: UTF-8 + raise ImportError(u'Not possible to import: ☺') + """) with pytest.raises(ImportError) as excinfo: pytestpm.import_plugin("qwe") - expected = '.*Error importing plugin "qwe": No module named \'?aaaa\'?' + expected = '.*Error importing plugin "qwe": Not possible to import: .' assert py.std.re.match(expected, str(excinfo.value)) |