omi icon indicating copy to clipboard operation
omi copied to clipboard

Stabilize neo grandfather source tests on Windows

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

Summary

  • read routers/payment.py and utils/subscription.py as UTF-8 in test_neo_desktop_grandfather.py
  • fix Windows non-UTF-8 locale failures in source-level Neo desktop grandfather tests
  • keep the existing grandfather policy assertions unchanged

Windows reproduction

Before this change on Windows with the default GBK locale:

  • python -m pytest tests\unit\test_neo_desktop_grandfather.py -q -> 3 failed, 16 passed, 1 warning
  • failures were UnicodeDecodeError: 'gbk' codec can't decode byte ... while reading routers/payment.py and utils/subscription.py

Testing

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

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

Greptile Summary

Adds encoding='utf-8' to three open() calls in test_neo_desktop_grandfather.py that read routers/payment.py and utils/subscription.py as source text. Without this, Python falls back to the system locale encoding on Windows (e.g. GBK), causing UnicodeDecodeError on any non-ASCII bytes in those files.

  • All three open() calls that inspect source files now pass encoding='utf-8' explicitly; test assertions are unchanged.
  • The fix is minimal and targeted — no other test logic or policy checks are affected.

Confidence Score: 5/5

Safe to merge — the change is a one-line encoding fix per call site with no logic impact.

All three open() calls that read Python source files as text now specify encoding='utf-8', which is the only change. Assertions are untouched and test coverage is unaffected. The fix is narrowly scoped to a real Windows locale bug and introduces no new risk.

No files require special attention.

Important Files Changed

Filename Overview
backend/tests/unit/test_neo_desktop_grandfather.py Adds explicit encoding='utf-8' to three open() calls that read source files, fixing UnicodeDecodeError on Windows with non-UTF-8 default locales (e.g. GBK). No logic changes.

Sequence Diagram

sequenceDiagram
    participant pytest
    participant test_neo_desktop_grandfather.py
    participant routers/payment.py
    participant utils/subscription.py

    pytest->>test_neo_desktop_grandfather.py: run tests
    test_neo_desktop_grandfather.py->>routers/payment.py: "open(encoding='utf-8')"
    routers/payment.py-->>test_neo_desktop_grandfather.py: source text (UTF-8)
    test_neo_desktop_grandfather.py->>test_neo_desktop_grandfather.py: assert current_period_start present x2
    test_neo_desktop_grandfather.py->>utils/subscription.py: "open(encoding='utf-8')"
    utils/subscription.py-->>test_neo_desktop_grandfather.py: source text (UTF-8)
    test_neo_desktop_grandfather.py->>test_neo_desktop_grandfather.py: assert reconcile + env-override strings present
    test_neo_desktop_grandfather.py-->>pytest: 19 passed

Reviews (1): Last reviewed commit: "Stabilize neo grandfather source tests o..." | Re-trigger Greptile

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