Read translation optimization source tests as UTF-8
Summary
- Read
transcribe.pyandtranslation_coordinator.pysource snapshots as UTF-8 intest_translation_optimization.py. - Fix Windows non-UTF-8 locale failures in the translation persistence guard source tests.
- Keep the existing translation optimization assertions unchanged.
Windows reproduction
Before this change on Windows with the default GBK locale:
python -m pytest tests\unit\test_translation_optimization.py -q->2 failed, 90 passed- failures were
UnicodeDecodeError: 'gbk' codec can't decode byte ...while readingrouters/transcribe.pyandutils/translation_coordinator.py
Testing
python -m pytest tests\unit\test_translation_optimization.py -q->92 passedpython -m black --line-length 120 --skip-string-normalization tests\unit\test_translation_optimization.py --checkpython -m py_compile tests\unit\test_translation_optimization.pygit diff --check origin/main...HEAD
Greptile Summary
This PR adds encoding='utf-8' to three open() calls in test_translation_optimization.py that read Python source files (routers/transcribe.py and utils/translation_coordinator.py) as text. Without this, the tests would fail with UnicodeDecodeError on Windows systems whose default locale uses a non-UTF-8 codec (e.g., GBK).
- Adds
encoding='utf-8'to all threeopen()calls that read source files inTestTranslateSegmentGuardWired, fixing Windows locale failures. - No test logic or assertions are changed — this is a pure compatibility fix.
Confidence Score: 5/5
Safe to merge — the change is a three-line encoding fix in a test file with no impact on production code.
The change exclusively adds encoding='utf-8' to file-read calls in tests. All three relevant open() calls in the file now carry the explicit encoding; no test logic or assertions were altered. The fix is portable and correct.
No files require special attention.
Important Files Changed
| Filename | Overview |
|---|---|
| backend/tests/unit/test_translation_optimization.py | Adds encoding='utf-8' to all three source-file open() calls in TestTranslateSegmentGuardWired; no other logic changes. |
Reviews (1): Last reviewed commit: "Read translation optimization source tes..." | Re-trigger Greptile