omi icon indicating copy to clipboard operation
omi copied to clipboard

Read people conversation source tests as UTF-8

Open tianmind-studio opened this issue 5 months ago • 1 comments

Summary

  • read routers/conversations.py and database/conversations.py as UTF-8 in test_people_conversations_500s.py
  • fix Windows non-UTF-8 locale failures in the source-level conversations list/no-photos checks
  • keep the existing people/conversation assertions unchanged

Windows reproduction

Before this change on Windows with the default GBK locale:

  • python -m pytest tests\unit\test_people_conversations_500s.py -q -> 3 failed, 11 passed, 1 warning
  • failures were UnicodeDecodeError: 'gbk' codec can't decode byte ... while reading database/conversations.py

Testing

  • python -m pytest tests\unit\test_people_conversations_500s.py -q -> 14 passed, 1 warning
  • python -m black --line-length 120 --skip-string-normalization tests\unit\test_people_conversations_500s.py --check
  • python -m py_compile tests\unit\test_people_conversations_500s.py
  • git diff --check --cached

tianmind-studio avatar Jun 10 '26 08:06 tianmind-studio

Greptile Summary

Fixes four open() calls in test_people_conversations_500s.py that read routers/conversations.py and database/conversations.py as source text, by adding encoding='utf-8'. Without this, Python uses the OS default encoding (e.g., GBK on Windows), causing UnicodeDecodeError when those files contain non-ASCII bytes.

  • All four open(path) calls in TestConversationsListNoPhotos now use open(path, encoding='utf-8'), making the tests locale-independent.
  • No test assertions, fixtures, or production code are modified.

Confidence Score: 5/5

The change is a one-line fix repeated four times — adding explicit UTF-8 encoding to file reads in a test file — with no impact on production code or test logic.

Only test-helper file reads are touched; all existing assertions remain identical. The fix correctly addresses the root cause (implicit OS encoding) and does not introduce any new behaviour or risk.

No files require special attention.

Important Files Changed

Filename Overview
backend/tests/unit/test_people_conversations_500s.py Adds encoding='utf-8' to four open() calls that read source files; no logic changes, fixes Windows GBK locale failures.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[pytest on Windows/GBK locale] --> B[open source file]
    B -->|Before: no encoding arg| C[OS default encoding e.g. GBK]
    B -->|After: encoding='utf-8'| D[UTF-8 decoding]
    C -->|non-ASCII byte in file| E[UnicodeDecodeError - test FAIL]
    D --> F[source read successfully]
    F --> G[assert function/decorator presence]
    G --> H[test PASS]

Reviews (1): Last reviewed commit: "Read people conversation source tests as..." | Re-trigger Greptile

greptile-apps avatar Jun 10 '26 08:06 greptile-apps