refactor(tests): reorganize noauto test cases by function; fix too-broad except - #1353
Merged
Conversation
…oad except Move misplaced test classes out of tokenize test files: ONNX tests (tests/noauto_onnx/): - TransliterateONNXTestCaseN → testn_transliterate_onnx.py - TagONNXTestCaseN → testn_tag_onnx.py - SpellONNXTestCaseN → testn_spell_onnx.py Torch tests (tests/noauto_torch/): - TransliterateTestCaseN → testn_transliterate_torch.py - ParseTestCaseN → testn_parse_torch.py - SummarizeTestCaseN → testn_summarize_torch.py - AugmentTestCaseN → testn_augment_torch.py Each new file adds edge-case tests: model-loaded checks, empty inputs, result structure (tuple pairs, string items), length constraints, and ValueError on out-of-range arguments. Update noauto_onnx/__init__.py and noauto_torch/__init__.py to register the new modules. Fix: remove dead try/except Exception wrapping list.append(2) in pythainlp/spell/wanchanberta_thai_grammarly.py (too-broad catch, unreachable except branch). Co-authored-by: bact <128572+bact@users.noreply.github.com> Agent-Logs-Url: https://github.com/PyThaiNLP/pythainlp/sessions/dbbd3773-7bc2-4463-a049-e17a95e2651f
Copilot
AI
changed the title
[WIP] Organise test cases by functions and increase test coverage
refactor(tests): reorganize noauto test cases by function; fix too-broad except
Mar 21, 2026
|
bact
approved these changes
Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Test classes in
testn_tokenize_onnx.pyandtestn_tokenize_torch.pycovered non-tokenization functionality (transliteration, tagging, spell, parse, summarize, augment), making failures hard to trace and suite boundaries meaningless. Also fixes a deadtry/except Exceptionin the spell module.Test reorganization — ONNX (
tests/noauto_onnx/)Extracted from
testn_tokenize_onnx.pyinto dedicated files:testn_transliterate_onnx.pyTransliterateONNXTestCaseNtestn_tag_onnx.pyTagONNXTestCaseNtestn_spell_onnx.pySpellONNXTestCaseNTest reorganization — Torch (
tests/noauto_torch/)Extracted from
testn_tokenize_torch.pyinto dedicated files:testn_transliterate_torch.pyTransliterateTestCaseNtestn_parse_torch.pyParseTestCaseNtestn_summarize_torch.pySummarizeTestCaseNtestn_augment_torch.pyAugmentTestCaseNBoth
__init__.pyfiles updated to register new modules in alphabetical order.Increased coverage
Each new file expands the original single-assertion tests with: model-loaded key checks (
<start>/<end>in vocab dicts), empty-input handling, result structure validation (tuple pairs, string items), length constraints, andValueErroron out-of-range arguments.Bug fix — too-broad
try/exceptpythainlp/spell/wanchanberta_thai_grammarly.py: theexcept Exceptionblock wrappinglabel_ids.append(2)was unreachable (list.appendnever raises) and silently swallowed any future logic errors in that branch.Your checklist for this pull request
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.