Fix exception formatting while importing test modules

Fix #2336
This commit is contained in:
Bruno Oliveira
2017-03-29 14:38:14 -03:00
parent 6cfe087261
commit 58ac4faf0c
4 changed files with 28 additions and 4 deletions

View File

@@ -105,6 +105,23 @@ class TestModule:
assert name not in stdout
def test_show_traceback_import_error_unicode(self, testdir):
"""Check test modules collected which raise ImportError with unicode messages
are handled properly (#2336).
"""
testdir.makepyfile(u"""
# -*- coding: utf-8 -*-
raise ImportError(u'Something bad happened ☺')
""")
result = testdir.runpytest()
result.stdout.fnmatch_lines([
"ImportError while importing test module*",
"Traceback:",
"*raise ImportError*Something bad happened*",
])
assert result.ret == 2
class TestClass:
def test_class_with_init_warning(self, testdir):
testdir.makepyfile("""