Read pusher ghost test sources as UTF-8 on Windows#7797
Conversation
Greptile SummaryThis PR fixes a Windows-locale portability issue in
Confidence Score: 5/5Safe to merge — the change is a targeted one-liner helper with consistent call-site updates, carrying no risk of changing test logic or production behaviour. The change is a single-file test utility addition where the new helper is an exact wrapper around the existing call with an explicit encoding parameter. Every call-site in the file has been updated, the fix matches the Python source-file encoding standard, and the PR author verified all 43 tests pass on both Windows and CI. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Test collection starts] --> B{OS locale}
B -->|Linux UTF-8| C[read_text uses system default]
B -->|Windows GBK before fix| D[read_text uses GBK codec]
B -->|Windows after fix| E[_read_source uses utf-8]
C --> F[Tests run normally]
D --> G[UnicodeDecodeError - collection fails]
E --> F
F --> H[43 tests pass]
Reviews (1): Last reviewed commit: "test(backend): read pusher ghost sources..." | Re-trigger Greptile |
Summary
_read_source()helper intest_pusher_ghost_connections.pythat reads source files withencoding='utf-8'.Why
On this Windows backend venv, collecting
test_pusher_ghost_connections.pyfailed before any assertions ran becausePath.read_text()used the system default GBK codec.routers/pusher.pycontains UTF-8 comments with non-ASCII punctuation, so the default decode raisedUnicodeDecodeError.The test is reading Python source for structural assertions, so using explicit UTF-8 matches Python source-file expectations and makes the test portable across Windows locales.
Testing
python -m pytest tests\unit\test_pusher_ghost_connections.py -q-> 43 passedpython -m black --line-length 120 --skip-string-normalization tests\unit\test_pusher_ghost_connections.py --checkpython -m py_compile tests\unit\test_pusher_ghost_connections.pygit diff --check -- backend/tests/unit/test_pusher_ghost_connections.py