pytest.fail with non-ascii characters raises an internal pytest error

Fix #1178
This commit is contained in:
Bruno Oliveira
2016-03-05 16:09:01 -03:00
parent 3884398055
commit 24d3e01548
4 changed files with 25 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
import _pytest._code
@@ -439,6 +440,24 @@ def test_pytest_fail_notrace(testdir):
assert 'def teardown_function' not in result.stdout.str()
def test_pytest_fail_notrace_unicode(testdir):
"""Fix pytest.fail with pytrace=False with non-ascii characters (#1178).
"""
testdir.makepyfile(u"""
# coding: utf-8
import pytest
def test_hello():
pytest.fail(u'oh oh: ☺', pytrace=False)
""")
result = testdir.runpytest()
if sys.version_info[0] >= 3:
result.stdout.fnmatch_lines(['*test_hello*', "oh oh: ☺"])
else:
result.stdout.fnmatch_lines(['*test_hello*', "oh oh: *"])
assert 'def test_hello' not in result.stdout.str()
def test_pytest_no_tests_collected_exit_status(testdir):
result = testdir.runpytest()
result.stdout.fnmatch_lines('*collected 0 items*')