-
-
Notifications
You must be signed in to change notification settings - Fork 71
Fix Windows emoji encoding issue causing test_fastapi_cli to fail [bugfix] [bug] #249
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
base: main
Are you sure you want to change the base?
Conversation
Changes applied: •logging.py: Added emoji=False and legacy_windows=True as a fallback. Also introduced force_terminal=True for console configuration. •cli.py: Added OS detection. When running on Windows, emoji output is disabled. •test_cli.py: Added platform checks to assertions involving emoji characters.
The change in logging.py was affecting other operating systems, it has now been corrected.
The change in logging.py was affecting other operating systems, it has now been corrected.
|
Hello @tiangolo. I noticed that I don't have permission to assign labels to the PR. Could you please tag it as 'bug' when you have a moment? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat surprised by this, as I've recently updated the test suite to cover Windows (PR 230) and there are no issues/failures for our CI Windows runners 🤔
What kind of system/shell are you using exactly?
Also, your screenshot is referring to a file tests/test_fastapi_cli.py that I don't see in the repo (anymore)?
|
The problem is caused by my use of PowerShell 5.1. Since it does not use UTF-8 by default, I encountered an error during testing. However, when running the tests locally, shouldn’t this error not occur? |
|
The reason there is no screenshot is that I cloned FastAPI. I originally encountered the error there. After that, I came here, and it turned out that the error was caused by this issue. |
|
It's just that I don't understand what this file |
Hello. On November 29, 2025 at 12:21, I cloned the FastAPI project to my local machine. After installing the dependencies, I ran the test suite with “pytest”. As a result, I encountered one failing test:
------------------------------------------------------Fail Message---------------------------------------------------------------
E + where '\n FastAPI FastAPI ' = CompletedProcess(args=['C:\Users\ertugrul\Desktop\fastapi\venv\Scripts\python.exe', '-m', 'coverage', 'run', '-...odeError: 'charmap' codec can't encode character '\U0001f680' in position 28: character maps to \n').stdout
tests\test_fastapi_cli.py:25: AssertionError
The failure was caused by emoji characters in the CLI output. These characters triggered an encoding issue on Windows systems, causing the test_fastapi_cli test to fail and the entire test suite to be marked as failed.
Changes applied:
• logging.py: Added emoji=False and legacy_windows=True as a fallback. Also introduced force_terminal=True for console configuration.
• cli.py: Added OS detection. When running on Windows, emoji output is disabled.
• test_cli.py: Added platform checks to assertions involving emoji characters.
After these changes, all tests now run successfully: ---- 2551 passed, 130 skipped in 24.89s ----