Add comprehensive robustness tests for real-world edge cases - #1202
Conversation
|
Hello @Copilot, thank you for submitting a PR! We will respond as soon as possible. สวัสดี @Copilot ขอบคุณที่ส่ง PR เข้ามา เราจะตอบกลับให้เร็วที่สุดเท่าที่จะทำได้ |
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
| f"Digit conversion failed with reserved string '{s}': {e}" | ||
| ) | ||
|
|
||
| def test_functions_do_not_execute_scripts(self): |
There was a problem hiding this comment.
Is this really helpful? Is the code in this test really able to capture the execution? @copilot
There was a problem hiding this comment.
You're right - the test doesn't actually detect code execution. I've renamed it to test_functions_handle_injection_strings_safely and clarified in the docstring that it's a robustness test verifying functions handle injection patterns without crashing, not an execution detection test. Since PyThaiNLP functions are text processors that don't interpret HTML/JS/SQL, the value is in ensuring they can handle these patterns gracefully. (commit b9e02d0)
…purpose Co-authored-by: bact <128572+bact@users.noreply.github.com>
|
@copilot word_tokenize() can have different engines, make the test cover it all |
… mm) Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Added test for very long strings addressing issue #893. The test includes repetitive patterns ("ชิ" * 50, "ด้านหน้า" * 20) and mixed patterns that can cause ambiguous breaking points. Uses newmm-safe engine which is designed to handle such cases without excessive processing time. (commit fb4a890) |
|
@copilot Recheck the worthiness of these new test cases. |
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Done! Streamlined the test suite from 18 tests (415 lines) to 2 focused tests (94 lines). Removed:
Kept:
The remaining tests provide genuine value without duplicating existing coverage. (commit 4063489) |
|
@copilot I think these tests are worth to have, let's keep it or add it:
|
…control chars Co-authored-by: bact <128572+bact@users.noreply.github.com>
Added all requested test categories! The test suite now includes:
All tested across 4 tokenization engines. Total: 7 test methods covering real-world edge cases. (commit e23bab7) |
|
@copilot there are some bidirectional, hidden, zero-width, or joiner characters in the test code now. This is not visible to human and can create issues. Please put those character as escaped one or as \u unicode point, so it is readable by both machine and human. Make the code more transparent. |
Co-authored-by: bact <128572+bact@users.noreply.github.com>
…ers" This reverts commit 88e7617.
|



What does this changes
Adds a comprehensive test suite (
tests/core/test_robustness.py) that tests real-world edge cases important for production usage:All tests validate behavior across 4 core tokenization engines (newmm, newmm-safe, longest, mm) to ensure consistent handling.
What was wrong
Text processing needs to handle various real-world edge cases that can cause crashes or incorrect output:
Existing tests lacked comprehensive coverage of these production edge cases and multi-engine validation across different tokenization algorithms.
How this fixes it
Implements comprehensive testing for production edge cases with multi-engine validation:
Empty and whitespace handling:
Special characters from encoding issues:
Emoji and modern Unicode:
Very long strings (issue #893):
Each test category is validated across all 4 tokenization engines to ensure consistent handling of edge cases. The test suite includes 51 test strings covering real-world scenarios from copy/paste operations, terminal input, different encodings, and modern text processing requirements.
Your checklist for this pull request
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.