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

UnicodeEncodeError #48

Open
vladislavfrolov opened this issue Apr 1, 2019 · 4 comments
Open

UnicodeEncodeError #48

vladislavfrolov opened this issue Apr 1, 2019 · 4 comments

Comments

@vladislavfrolov
Copy link

  • HtmlTestRunner version: 1.2
  • Python version: 3.7.0
  • Operating System: Windows 10

Description

I was trying to get report generated and saved in my local folder, but I got this error

Traceback (most recent call last):
  File "test_suite_runner.py", line 24, in <module>
    runner.run(all_tests_suite)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\HtmlTestRunner\runner.py", line 112, in run
    result.generate_reports(self)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\HtmlTestRunner\result.py", line 367, in generate_reports
    self.generate_file(testRunner, report_name_body, html_file)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\HtmlTestRunner\result.py", line 404, in generate_file
    report_file.write(report)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u20bd' in position 3929: character maps to <undefined>

What I Did

What helped me get rid of this error was adding encoding='utf-8' in generate_file() in result.py on line 403

with open(path_file, 'w', encoding='utf-8') as report_file:
    report_file.write(report)

I'm very new to programming so I don't know if you need to do something with this or this is my local problem.

@R-N
Copy link

R-N commented Mar 9, 2020

Hello, I'm experiencing this too. I have added encoding utf-8 option too, but it doesn't work. The characters were \x84 and \x99. Thanks

Edit: Didn't know I had to do it on the source code of HtmlTestRunner. The one I added encoding option to was the stream argument (which seems to be not what I expected)

@RoshanRajkumar1208
Copy link

hello guyz, facing the same issue, where can i get the result.py(), i am unable to locate it in my machine

@RoshanRajkumar1208
Copy link

  • HtmlTestRunner version: 1.2
  • Python version: 3.7.0
  • Operating System: Windows 10

Description

I was trying to get report generated and saved in my local folder, but I got this error

Traceback (most recent call last):
  File "test_suite_runner.py", line 24, in <module>
    runner.run(all_tests_suite)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\HtmlTestRunner\runner.py", line 112, in run
    result.generate_reports(self)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\HtmlTestRunner\result.py", line 367, in generate_reports
    self.generate_file(testRunner, report_name_body, html_file)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\HtmlTestRunner\result.py", line 404, in generate_file
    report_file.write(report)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u20bd' in position 3929: character maps to <undefined>

What I Did

What helped me get rid of this error was adding encoding='utf-8' in generate_file() in result.py on line 403

with open(path_file, 'w', encoding='utf-8') as report_file:
    report_file.write(report)

I'm very new to programming so I don't know if you need to do something with this or this is my local problem.

where do you find the result.py()?

@vladislavfrolov
Copy link
Author

vladislavfrolov commented Sep 7, 2021

where do you find the result.py()?

@RoshanRajkumar1208 It's in HtmlTestRunner package (https://github.com/oldani/HtmlTestRunner/blob/master/HtmlTestRunner/result.py). Try to look at C:\Python39\Lib\site-packages or something like it, depends on how you installed Python and wich OS you use.

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

3 participants