oldani / HtmlTestRunner

A Test Runner in python, for Human Readable HTML Reports
MIT License
295 stars 171 forks source link

fix UnicodeEncodeError occured when reports generated with special chars #90

Closed trialhub123 closed 2 months ago

trialhub123 commented 2 years ago

adding encoding='utf-8' in generate_file() in result.py on line 403 to fix issue below:

Traceback (most recent call last): File "C:\Python37\lib\site-packages\HtmlTestRunner\runner.py", line 112, in run result.generate_reports(self) File "C:\Python37\lib\site-packages\HtmlTestRunner\result.py", line 388, in generate_reports self.generate_file(testRunner, report_name_body, html_file) File "C:\Python37\lib\site-packages\HtmlTestRunner\result.py", line 404, in generate_file report_file.write(report) File "C:\Python37\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 68858-68859: character maps to

Also see an issue in github about the same - https://github.com/oldani/HtmlTestRunner/issues/48