Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occurs UnicodeEncodeError when failure message contains non-ascii symbols #77

Closed
RockBomber opened this issue Jul 1, 2017 · 1 comment

Comments

@RockBomber
Copy link
Contributor

I'm submitting a bug report

Сurrent behavior: occurs UnicodeEncodeError when failure message contains non-ascii symbols

The steps to reproduce and a minimal demo of the problem:
Create simple PyTest test:

def test_2():
    assert False, 'Большая беда'

Then run it: pytest test_2.py --alluredir aresult

You will got an error:

...
INTERNALERROR>   File "/home/bomber/.virtualenvs/autotesting/local/lib/python2.7/site-packages/allure_pytest/listener.py", line 134, in pytest_runtest_makereport
INTERNALERROR>     status_details = StatusDetails(message=str(call.excinfo.exconly()), trace=str(report.longrepr))
INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-22: ordinal not in range(128)

Expected behavior: test must fails without INTERNALERROR, allure report must contain failure message with non-ascii symbols.

Environment:

@RockBomber
Copy link
Contributor Author

Possible solution:

diff --git a/allure-pytest/src/listener.py b/allure-pytest/src/listener.py
index 1901721..d35335c 100644
--- a/allure-pytest/src/listener.py
+++ b/allure-pytest/src/listener.py
@@ -131,7 +131,7 @@ class AllureListener(object):
         elif hasattr(report, 'wasxfail'):
             status_details = StatusDetails(message=report.wasxfail)
         elif report.failed:
-            status_details = StatusDetails(message=str(call.excinfo.exconly()), trace=str(report.longrepr))
+            status_details = StatusDetails(message=call.excinfo.exconly(), trace=report.longreprtext)
 
         if report.when == 'setup':
             if report.passed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant