Skip to content

Read translation optimization source tests as UTF-8#7782

Open
tianmind-studio wants to merge 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/translation-optimization-source-test-windows
Open

Read translation optimization source tests as UTF-8#7782
tianmind-studio wants to merge 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/translation-optimization-source-test-windows

Conversation

@tianmind-studio

Copy link
Copy Markdown
Contributor

Summary

  • Read transcribe.py and translation_coordinator.py source snapshots as UTF-8 in test_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 reading routers/transcribe.py and utils/translation_coordinator.py

Testing

  • python -m pytest tests\unit\test_translation_optimization.py -q -> 92 passed
  • python -m black --line-length 120 --skip-string-normalization tests\unit\test_translation_optimization.py --check
  • python -m py_compile tests\unit\test_translation_optimization.py
  • git diff --check origin/main...HEAD

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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 three open() calls that read source files in TestTranslateSegmentGuardWired, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant