Python encoding error while trying to debug but not when running from terminal

119 Views Asked by At

UPDATE: I was able to fix the issue, turns out my laptop's language was set to English UK and it looks like it uses a different encoding than expected. I found the solution + fix here. Thank you for trying to help.

Tried searching for a solution but nothing worked until now. I am a new to the team and trying to debug failing automated tests, I'm able to run the tests using the command line but when using Pycharm's internal runner and/or debugger the tests always fail after the last line of the before_class method and before even entering the first line of the actual test, this happens for all the tests.

I'm getting the following error, already tried setting the project encoding and removed any print methods bring called. other people in my team are able to use it correctly. I should mention the app is in Hebrew and every tests has some comments in Hebrew as well, this do not make any difference to the command line run and my team mates. any ideas?

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\_pytest\main.py", line 269, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\_pytest\main.py", line 323, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\_pytest\main.py", line 348, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\_pytest\runner.py", line 109, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\_pytest\runner.py", line 120, in runtestprotocol
INTERNALERROR>     rep = call_and_report(item, "setup", log)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\_pytest\runner.py", line 219, in call_and_report
INTERNALERROR>     hook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "C:\Work Repos\BusinessApp\venv\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\pytest_plugin.py", line 306, in pytest_runtest_logreport
INTERNALERROR>     self.report_test_output(report, test_id)
INTERNALERROR>   File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\pytest_plugin.py", line 206, in report_test_output
INTERNALERROR>     dump_test_stdout(self.teamcity, test_id, test_id, data)
INTERNALERROR>   File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\common.py", line 73, in dump_test_stdout
INTERNALERROR>     messages.testStdOut(test_id, chunk, flowId=flow_id)
INTERNALERROR>   File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\messages.py", line 187, in testStdOut
INTERNALERROR>     self.message('testStdOut', name=testName, out=out, flowId=flowId)
INTERNALERROR>   File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\_jb_runner_tools.py", line 117, in message
INTERNALERROR>     _old_service_messages.message(self, messageName, **properties)
INTERNALERROR>   File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\messages.py", line 101, in message
INTERNALERROR>     retry_on_EAGAIN(self.output.write)(self.encode(message))
INTERNALERROR>   File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\messages.py", line 68, in encode
INTERNALERROR>     value = value.encode(self.encoding)
INTERNALERROR>   File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 12, in encode
INTERNALERROR>     return codecs.charmap_encode(input,errors,encoding_table)
INTERNALERROR> UnicodeEncodeError: 'charmap' codec can't encode characters in position 1378-1383: character maps to <undefined>

====================== no tests ran in 83.20s (0:01:23) =======================

Process finished with exit code 3
0

There are 0 best solutions below