langextract icon indicating copy to clipboard operation
langextract copied to clipboard

Add edge case tests for prompt validation (fixes #316)

Open Nedas-Jaronis opened this issue 9 months ago • 16 comments

Description

Fixes #316

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:

  1. test_empty_extraction_text() - Verify that empty strings are properly rejected with ValueError
  2. test_unicode_and_special_chars() - Ensure proper handling of unicode characters
  3. 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

Result: 3 passed ✅

Full test suite:

python -m pytest tests/prompt_validation_test.py -v

Result: 395 passed, 77 warnings ✅

Testing environment:

  • OS: Windows 11
  • Python: 3.13.3
  • Branch: Open-Soruce-Contribution

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 #316

Nedas-Jaronis avatar Feb 12 '26 19:02 Nedas-Jaronis

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Feb 12 '26 19:02 google-cla[bot]

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Feb 25 '26 16:02 github-actions[bot]

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Mar 05 '26 02:03 github-actions[bot]

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Mar 12 '26 02:03 github-actions[bot]

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Mar 19 '26 03:03 github-actions[bot]

⚠️ Branch Update Required

Your branch is 7 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Mar 26 '26 03:03 github-actions[bot]

⚠️ Branch Update Required

Your branch is 8 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Apr 02 '26 05:04 github-actions[bot]

⚠️ Branch Update Required

Your branch is 11 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Apr 10 '26 03:04 github-actions[bot]

⚠️ Branch Update Required

Your branch is 15 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Apr 18 '26 03:04 github-actions[bot]

⚠️ Branch Update Required

Your branch is 22 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Apr 26 '26 03:04 github-actions[bot]

⚠️ Branch Update Required

Your branch is 29 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar May 03 '26 03:05 github-actions[bot]

⚠️ Branch Update Required

Your branch is 29 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar May 10 '26 03:05 github-actions[bot]

⚠️ Branch Update Required

Your branch is 31 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar May 17 '26 03:05 github-actions[bot]

⚠️ Branch Update Required

Your branch is 36 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar May 25 '26 03:05 github-actions[bot]

⚠️ Branch Update Required

Your branch is 36 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Jun 01 '26 03:06 github-actions[bot]

⚠️ Branch Update Required

Your branch is 36 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Jun 09 '26 03:06 github-actions[bot]

⚠️ Branch Update Required

Your branch is 36 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Jun 16 '26 03:06 github-actions[bot]

⚠️ Branch Update Required

Your branch is 36 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Jun 24 '26 03:06 github-actions[bot]

⚠️ Branch Update Required

Your branch is 36 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Jul 01 '26 03:07 github-actions[bot]

⚠️ Branch Update Required

Your branch is 39 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

github-actions[bot] avatar Jul 09 '26 03:07 github-actions[bot]