Skip to content

Commit 7515396

Browse files
ehborisovsseliverstov
authored andcommitted
don't use encode('utf-8').decode('unicode_escape') (fixes #229 fixes #198 via #243)
1 parent 08145b1 commit 7515396

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

allure-pytest/src/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def escape_name(name):
105105
name.decode('string_escape').encode('unicode_escape')
106106
except UnicodeDecodeError:
107107
return name.decode('string_escape').decode('utf-8')
108-
return name.encode('utf_8').decode('unicode_escape')
108+
return name.encode('ascii', 'backslashreplace').decode('unicode_escape')
109109

110110

111111
def get_outcome_status(outcome):

allure-pytest/test/conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,12 @@ def allure_report(request, tmpdir_factory):
7878

7979
def pytest_collection_modifyitems(items, config):
8080
if config.option.doctestmodules:
81-
items[:] = [item for item in items if item.__class__.__name__ == 'DoctestItem']
81+
items[:] = [item for item in items if item.__class__.__name__ == 'DoctestItem']
82+
83+
84+
def pytest_ignore_collect(path, config):
85+
if sys.version_info.major < 3 and "py3_only" in path.strpath:
86+
return True
87+
88+
if sys.version_info.major > 2 and "py2_only" in path.strpath:
89+
return True

allure-pytest/test/utf_identifier/__init__.py

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
3+
4+
def test_utf_func_déjà_vu():
5+
"""
6+
>>> allure_report = getfixture('allure_report')
7+
>>> assert_that(allure_report,
8+
... has_test_case('test_utf_func_déjà_vu')
9+
... )
10+
"""
11+
assert False
12+
13+
14+
class TestScenario:
15+
16+
def test_utf_method_例子(self):
17+
"""
18+
>>> allure_report = getfixture('allure_report')
19+
>>> assert_that(allure_report,
20+
... has_test_case('test_utf_method_例子')
21+
... )
22+
"""
23+
pass

allure-pytest/tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ passenv = HOME
1010

1111
whitelist_externals = rm
1212

13+
setenv = ALLURE_INDENT_OUTPUT=yep
14+
1315
deps =
1416
pyhamcrest
1517
{distshare}/allure-python-commons-2*.zip

0 commit comments

Comments
 (0)