I'm submitting a ...
What is the current behavior?
Allure cant escape test name when meet \\u in test parameter value and throws UnicodeDecodeError exception.
Reproduction
Run code below with argument --alluredir=somedir
import pytest
@pytest.mark.parametrize('param', ['\\u'])
def test_decode_error( param):
pass
Trace:
pytest test_allure.py --alluredir=allure-results -v
============================= test session starts =============================
platform win32 -- Python 2.7.15, pytest-3.7.1, py-1.5.4, pluggy-0.7.1 -- c:\git\allure_error\venv\scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\GIT\allure_error, inifile:
plugins: allure-pytest-2.5.0
collected 1 item
test_allure.py::test_decode_error[C:\source\unigine.vcxproj-/p:Platform=x64] ERROR [100%]
=================================== ERRORS ====================================
ERROR at setup of test_decode_error[C:\source\unigine.vcxproj-/p:Platform=x64]
self = <allure_pytest.listener.AllureListener object at 0x06697590>
item = <Function 'test_decode_error[C:\\source\\unigine.vcxproj-/p:Platform=x64]'>
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_setup(self, item):
uuid = self._cache.set(item.nodeid)
test_result = TestResult(name=item.name, uuid=uuid)
self.allure_logger.schedule_test(uuid, test_result)
yield
uuid = self._cache.get(item.nodeid)
test_result = self.allure_logger.get_test(uuid)
for fixturedef in _test_fixtures(item):
group_uuid = self._cache.get(fixturedef)
if not group_uuid:
group_uuid = self._cache.set(fixturedef)
group = TestResultContainer(uuid=group_uuid)
self.allure_logger.start_group(group_uuid, group)
self.allure_logger.update_group(group_uuid, children=uuid)
params = item.callspec.params if hasattr(item, 'callspec') else {}
> test_result.name = allure_name(item, params)
venv\lib\site-packages\allure_pytest\listener.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
venv\lib\site-packages\allure_pytest\utils.py:88: in allure_name
name = escape_name(item.name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
name = 'test_decode_error[C:\\source\\unigine.vcxproj-/p:Platform=x64]'
def escape_name(name):
if six.PY2:
try:
name.decode('string_escape').encode('unicode_escape')
except UnicodeDecodeError:
return name.decode('string_escape').decode('utf-8')
> return name.encode('ascii', 'backslashreplace').decode('unicode_escape')
E UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 27-28: truncated \uXXXX escape
venv\lib\site-packages\allure_pytest\utils.py:108: UnicodeDecodeError
Environment:
- Allure version: 2.7.0
- Test framework: pytest@3.7.1
- Allure adaptor: allure-pytest@2.5.0
- Python version: 2.7.15
Other information
Without --alluredir argument exception is not appears
I'm submitting a ...
What is the current behavior?
Allure cant escape test name when meet
\\uin test parameter value and throws UnicodeDecodeError exception.Reproduction
Run code below with argument
--alluredir=somedirTrace:
Environment:
Other information
Without
--alluredirargument exception is not appears