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

The runner will report error if the testcase output include chinese random code #66

Open
zmayw opened this issue May 22, 2020 · 1 comment · May be fixed by #75
Open

The runner will report error if the testcase output include chinese random code #66

zmayw opened this issue May 22, 2020 · 1 comment · May be fixed by #75

Comments

@zmayw
Copy link

zmayw commented May 22, 2020

  • HtmlTestRunner version: 1.2.1
  • Python version:Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
  • Operating System:

Description

I use the HtmlTESTRunner, it reports the follow error.
Becouse of my testcase is output the conent like "[{'Text': 'æ\x96°å\x91\x98å·¥å\x85¥è\x81\x8c', ...}]"
so I modify the code of HTMLTESTRunner/result.py in 404, as "with open(path_file, 'w', encoding='utf-8') as report_file:", its running is ok!
Is this line code need to modify?
Traceback (most recent call last):
File "D:/autotest/testProject/testcase/suite/suite_test01.py", line 26, in
runner.run(suite)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\HtmlTestRunner\runner.py", line 112, in run
result.generate_reports(self)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\HtmlTestRunner\result.py", line 367, in generate_reports
self.generate_file(testRunner, report_name_body, html_file)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\HtmlTestRunner\result.py", line 404, in generate_file
report_file.write(report)
UnicodeEncodeError: 'gbk' codec can't encode character '\xe6' in position 9767: illegal multibyte sequence

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
@mapleflow
Copy link

windows chinese read/write default gbk,unix always custom utf8.
when read/write encoding is best practice

@dongfangtianyu dongfangtianyu linked a pull request Sep 17, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants