langextract
langextract copied to clipboard
Add edge case tests for prompt validation
Fixes #316
Description
This PR adds three new edge case tests to improve test coverage for the prompt validation module, addressing gaps in error handling and boundary condition testing.
Problem
The prompt validation test suite lacks coverage for important edge cases that could cause unexpected behavior in production:
- Empty extraction text handling
- Unicode characters and special symbols (café, °F, etc.)
- Very long extraction text (1000+ characters)
Proposed Solution
Add three new test cases to tests/prompt_validation_test.py:
-
test_empty_extraction_text()- Verify that empty strings are properly rejected with ValueError -
test_unicode_and_special_chars()- Ensure proper handling of unicode characters -
test_very_long_extraction_text()- Test graceful handling of very long extractions
Benefits
- ✅ Improves reliability by catching edge case bugs early
- ✅ Better test coverage for error handling paths
- ✅ Documents expected behavior for edge cases
- ✅ Follows existing test patterns and conventions
How Has This Been Tested?
All three tests pass successfully:
python -m pytest tests/prompt_validation_test.py::PromptAlignmentValidationTest::test_empty_extraction_text -v
python -m pytest tests/prompt_validation_test.py::PromptAlignmentValidationTest::test_unicode_and_special_chars -v
python -m pytest tests/prompt_validation_test.py::PromptAlignmentValidationTest::test_very_long_extraction_text -v
Checklist
- [x] Code follows project style
- [x] Self-review completed
- [x] Tests added
- [x] All tests pass
- [x] Focused single change
- [x] Linked to issue