Skip to content

Read people conversation source tests as UTF-8#7780

Open
tianmind-studio wants to merge 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/people-conversations-source-utf8-windows
Open

Read people conversation source tests as UTF-8#7780
tianmind-studio wants to merge 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/people-conversations-source-utf8-windows

Conversation

@tianmind-studio

Copy link
Copy Markdown
Contributor

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

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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]
Loading

Reviews (1): Last reviewed commit: "Read people conversation source tests as..." | 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