Add unit tests for group_contiguous_integers#210
Merged
Conversation
This module-level utility (used by join_on_conjunctions) had no direct test coverage of its own, only indirect coverage through HumanName-level parsing tests. Add focused tests for its documented contract: empty/isolated/single values return no ranges, adjacent pairs are the smallest valid run, multiple separate runs are found independently, and out-of-order input isn't treated as contiguous (the function assumes ascending, strictly increasing input).
Code review noted the comment attributed the empty result to "unsorted input" generally, when the actual mechanism is that the groupby key (enumerate index - value) only repeats across an ascending run; a descending sequence changes the key at every step.
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.
Summary
group_contiguous_integers(nameparser/parser.py) is a pure, module-level utility used byjoin_on_conjunctionsto find contiguous runs of conjunction indices, but had no direct test coverage — only indirect coverage through HumanName-level parsing tests.tests/test_parser_util.pywith focused tests for its actual contract: empty input, isolated single values, the smallest valid run (an adjacent pair), a single run, multiple separate runs, isolated values between runs, and a note that it assumes ascending/strictly-increasing input (unsorted input isn't treated as contiguous).Follow-up from #209, split out per review discussion since this function itself wasn't touched by that PR.
Test plan
python -m pytest tests/test_parser_util.py -v— 16 passed (8 tests × default/none config parametrization)python -m pytest -q— 1272 passed, 4 skipped, 22 xfailed (up from 1256 baseline by exactly the 16 new test cases; zero regressions)