Skip to content

test: add unit tests for locale module#565

Open
JiayuuWang wants to merge 3 commits into666ghj:mainfrom
JiayuuWang:contribot/test-locale
Open

test: add unit tests for locale module#565
JiayuuWang wants to merge 3 commits into666ghj:mainfrom
JiayuuWang:contribot/test-locale

Conversation

@JiayuuWang
Copy link
Copy Markdown

Summary

  • Add unit tests for locale file structure and completeness
  • Tests verify translation files (en.json, zh.json) have proper structure

Test Coverage

  • TestLocaleStructure:
    • languages.json has required fields (zh/en labels and llmInstruction)
    • zh and en translations have common keys (confirm, cancel, loading, etc.)
    • zh and en have same top-level keys
    • translation interpolation uses {var} format
  • TestLanguagesCompleteness:
    • existing translation files (en, zh) have consistent structure

Test Plan

  • Run python -m pytest tests/test_locale.py -v - all 7 tests pass

🤖 Generated with Claude Code

MiroFish Contributor and others added 3 commits April 21, 2026 00:02
When the LLM generates a <tool_call> block followed by a self-generated
<tool_result> block in the same response, the fake result must be stripped
before appending to message history. The real tool result will be injected
separately by the system.

This fixes a React Hallucination bug where models could fabricate tool
results that didn't actually come from tool invocations.
- Added pytest.ini configuration for test discovery
- Added tests/__init__.py package marker
- Added 22 unit tests covering:
  - _read_text_with_fallback: UTF-8, GBK, Latin-1, replacement chars
  - FileParser: extensions, nonexistent file, unsupported format, md/txt extraction
  - FileParser.extract_from_multiple: valid files and error handling
  - split_text_into_chunks: short text, empty text, chunk size, overlap, sentence boundaries

All tests pass with direct module import to avoid Flask initialization issues.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Add tests for locale file structure and completeness:
- Test languages.json has required fields (zh, en labels, llmInstruction)
- Test zh/en translations have common keys (confirm, cancel, etc.)
- Test zh and en have same top-level keys
- Test translation interpolation format ({var} placeholders)
- Test existing translation files have consistent structure

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant