Fix Windows emoji encoding issue causing test_fastapi_cli to fail [bugfix] [bug]
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
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 ----
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.