Stabilize memories create source tests on Windows
Summary
- read
routers/memories.pyas UTF-8 intest_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 readingrouters/memories.py
Testing
python -m pytest tests\unit\test_memories_create.py -q-> 22 passedpython -m black --line-length 120 --skip-string-normalization tests\unit\test_memories_create.py --checkpython -m py_compile tests\unit\test_memories_create.pygit diff --check
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 gainencoding='utf-8'in theiropen()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
Reviews (1): Last reviewed commit: "Stabilize memories create source tests o..." | Re-trigger Greptile