Skip to content

Stabilize memories create source tests on Windows#7777

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

Stabilize memories create source tests on Windows#7777
tianmind-studio wants to merge 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/memories-create-source-utf8-windows

Conversation

@tianmind-studio

Copy link
Copy Markdown
Contributor

Summary

  • read routers/memories.py as UTF-8 in test_memories_create.py
  • fix Windows non-UTF-8 locale failures in source-level memories create/router tests
  • keep the existing rate-limit and error-handling assertions unchanged

Windows reproduction

Before this change on Windows with the default GBK locale:

  • python -m pytest tests\unit\test_memories_create.py -q -> 13 failed, 9 passed
  • failures were UnicodeDecodeError: 'gbk' codec can't decode byte ... while reading routers/memories.py

Testing

  • python -m pytest tests\unit\test_memories_create.py -q -> 22 passed
  • python -m black --line-length 120 --skip-string-normalization tests\unit\test_memories_create.py --check
  • python -m py_compile tests\unit\test_memories_create.py
  • git diff --check

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a Windows-only test failure caused by Python's open() defaulting to the system locale encoding (e.g. GBK) instead of UTF-8 when reading routers/memories.py. Both file-reading helpers now pass encoding='utf-8' explicitly.

  • _read_router() and _grep_router() each gain encoding='utf-8' in their open() calls — the only two places the router source is read.
  • All existing rate-limit and error-handling assertions are preserved without modification.

Confidence Score: 5/5

Safe to merge — two-line change adds explicit UTF-8 encoding to file reads in tests with no production code touched.

The change is isolated to a test helper file: two open() calls gain encoding='utf-8', which is the standard cross-platform fix for reading UTF-8 source files. No logic is altered, no assertions are changed, and the fix directly addresses the documented Windows failure mode.

No files require special attention.

Important Files Changed

Filename Overview
backend/tests/unit/test_memories_create.py Adds explicit encoding='utf-8' to both open() calls in _read_router() and _grep_router() to prevent UnicodeDecodeError on Windows non-UTF-8 locales; no logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[pytest collects test] --> B{Test class}
    B --> C[TestMemoriesRateLimitWiring]
    B --> D[TestCreateMemoryErrorHandling]
    C --> E["_grep_router(pattern)\nopen(ROUTER_PATH, encoding='utf-8')"]
    D --> F["_read_router()\nopen(ROUTER_PATH, encoding='utf-8')"]
    E --> G[Iterate lines, re.search match]
    F --> H[Return full source string]
    G --> I[Assert count / content]
    H --> I
Loading

Reviews (1): Last reviewed commit: "Stabilize memories create source tests o..." | 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