Change8
Error1 reports

Fix UnicodeEncodeError

in pytest

Solution

UnicodeEncodeError in pytest often arises when the test output (including captured stdout/stderr, or parametrization values) contains characters that cannot be encoded using the default terminal encoding (like ASCII). Force pytest to use UTF-8 encoding by setting the `PYTHONIOENCODING=utf-8` environment variable before running pytest, or configure your system to use UTF-8 as the default encoding to ensure consistent encoding across environments.

Related Issues

Real GitHub issues where developers encountered this error:

Timeline

First reported:Sep 24, 2025
Last reported:Sep 24, 2025

Need More Help?

View the full changelog and migration guides for pytest

View pytest Changelog