Skip to content

test: add unit tests for file_parser module#562

Open
JiayuuWang wants to merge 2 commits into666ghj:mainfrom
JiayuuWang:contribot/test-file-parser
Open

test: add unit tests for file_parser module#562
JiayuuWang wants to merge 2 commits into666ghj:mainfrom
JiayuuWang:contribot/test-file-parser

Conversation

@JiayuuWang
Copy link
Copy Markdown

Summary

  • Added pytest.ini configuration for test discovery in the backend
  • Added backend/tests/__init__.py package marker
  • Added 22 unit tests for file_parser module covering:
    • _read_text_with_fallback: UTF-8, GBK, Latin-1 encoding handling, replacement characters
    • FileParser: supported extensions, file existence checks, unsupported format handling, md/txt extraction
    • FileParser.extract_from_multiple: batch extraction with valid files and error handling
    • split_text_into_chunks: short text, empty text, chunk size limits, overlap handling, sentence boundary splitting

Test plan

  • All 22 tests pass
  • Tests use direct module import to avoid Flask initialization issues
  • Tests cover both success and error paths

🤖 Generated with Claude Code

MiroFish Contributor and others added 2 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 <noreply@anthropic.com>
@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