Repository navigation
Five unit test files hold their literal-duplicate cases as parametrize tables - #294
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tifier Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…oken handle keeps its own test, a seven-digit row pins the zero-padded shape Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ding splits into the named and the none cases Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… own table, the shape test's name reads as a sentence Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e -s and -ed length guards Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…able name say what each row pins Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
...
Why
A scan of
tests/unitfor test functions whose bodies are identical once their literals are replaced found 95 groups in 19,096 functions. That is 129 functions that differ from a sibling only in the values they pass. These five files hold the largest groups, 33 of the 129. Each group, with the neighbouring tests of the same shape that differ in a name or a second call, is now apytest.mark.parametrizetable whose name holds for every row, 38 functions fewer. Every case keeps an id that names the behaviour it pins, so a failure still says which case broke. The comment that explained a case moved onto its row.test_entity_stable_keys.pytest_lemmatize.pytest_identifier_grounding.pytest_migrate_settings.pytest_injectable_identifiers.pyThe other 96 duplicate functions are pairs and triples spread over 68 files, many of them in areas other open pull requests are changing. Folding them saves no CI time, since a parametrized case costs what a function did. The CI time comes from running the suites in parallel (#287, #288, #290).
Scope and risk
Five unit test files. No server code. No case is dropped: each removed function's assertion is a row in the table that replaces it. Four functions held two
lemmatizeassertions each, and each assertion is now its own case. Three cases are new. One is a seven-digit zero-padded id, which only the zero-padded-id shape of_injectable_identifierscatches (the five-digit id already in the file,05059, is caught by the salient-number path first, so no row pinned the zero-padded shape). The other two are lemmatize rows,itsandused, each one character too short for its rule: the old short-word test claimed to pin the length guard, butthematches no rule, so no row pinned a guard against a word one character too short. 64 cases became 71.test_entity_stable_keys.py::test_pr_number_in_value_prefixes_keytest_entity_stable_key_prefixes_the_salient_entity[PR number in the value]…::test_pr_number_no_separator_prefixes_key…[PR number without a separator, from the entities]…::test_bare_hash_ref_treated_as_pr…[bare hash ref is a PR]…::test_issue_number_prefixes_with_issue…[issue number prefixes with issue]…::test_handle_prefixes_key…[handle in the value]…::test_handle_from_entities_list…[handle from the entities]…::test_test_keyword_id_prefixes_key…[test keyword and id]…::test_bare_test_file_convention_prefixes_key…[bare test file convention]…::test_no_entity_leaves_key_unchangedtest_entity_stable_key_leaves_a_key_without_a_salient_entity[no entity leaves the key]…::test_lone_small_number_is_not_a_prtest_entity_stable_key_leaves_a_key_without_a_salient_entity[lone small number is not a PR]…::test_concept_suffix_strips_multiple_generic_prefixestest_entity_stable_key_prefixes_the_salient_entity[several generic prefixes stripped]…::test_all_generic_key_is_not_stripped_to_emptytest_entity_stable_key_prefixes_the_salient_entity[all-generic key not emptied]…::test_priority_pr_beats_handletest_entity_stable_key_prefixes_the_salient_entity[PR beats handle]…::test_handle_ignores_email_local_parttest_entity_stable_key_leaves_a_key_without_a_salient_entity[email local part is not a handle]test_lemmatize.py::test_plural_to_singulartest_lemmatize_strips_the_suffixes_of_each_token[plural to singular],[plural to singular, short stem]…::test_gerund_to_stem…[gerund to stem]…::test_past_tense_to_stem…[past tense to stem]…::test_ies_to_y…[ies to y],[ies to y, long stem]…::test_ier_to_y…[ier to y]…::test_case_insensitive…[case insensitive],[case insensitive, all caps]…::test_punctuation_passes_through_as_spaces…[punctuation passes as spaces]…::test_irregular_words_pass_throughtest_lemmatize_leaves_or_drops_a_token_no_rule_applies_to[irregular word passes through]…::test_short_words_unchangedtest_lemmatize_leaves_or_drops_a_token_no_rule_applies_to[no suffix rule matches],[single char dropped]…::test_double_letters_intentional_imperfectiontest_lemmatize_strips_the_suffixes_of_each_token[double letter kept]…::test_empty_inputtest_empty_input_lemmatizes_to_nothing, with both its assertionstest_identifier_grounding.py::test_pr_number_absent_from_hits_returns_reasontest_identifier_grounding_missing_names_the_first_identifier_when_none_is_grounded[PR number absent]…::test_pr_number_present_in_a_hit_returns_nonetest_identifier_grounding_missing_is_none_when_an_identifier_is_grounded_or_there_is_none[PR number present]…::test_hash_and_bare_number_forms_ground_the_same_idtest_identifier_grounding_missing_is_none_when_an_identifier_is_grounded_or_there_is_none[hash and bare number]…::test_handle_absent_returns_reasontest_identifier_grounding_missing_names_the_first_identifier_when_none_is_grounded[handle absent]…::test_handle_present_returns_nonetest_identifier_grounding_missing_is_none_when_an_identifier_is_grounded_or_there_is_none[handle present]…::test_no_identifier_query_returns_nonetest_identifier_grounding_missing_is_none_when_an_identifier_is_grounded_or_there_is_none[no identifier]…::test_grounding_is_case_insensitivetest_identifier_grounding_missing_is_none_when_an_identifier_is_grounded_or_there_is_none[case insensitive]…::test_multiple_identifiers_one_present_returns_nonetest_identifier_grounding_missing_is_none_when_an_identifier_is_grounded_or_there_is_none[one of several present]…::test_multiple_identifiers_all_absent_returns_firsttest_identifier_grounding_missing_names_the_first_identifier_when_none_is_grounded[all absent names the first]…::test_empty_hits_with_identifier_returns_reasontest_identifier_grounding_missing_names_the_first_identifier_when_none_is_grounded[no hits]test_migrate_settings.py::test_statistics_statement_gets_statistics_flagtest_a_statement_gets_the_flags_its_features_or_table_need[statistics]…::test_nlp_stem_statement_gets_nlp_flag…[nlp stem]…::test_vector_similarity_index_gets_vector_flag…[vector similarity index]…::test_plain_statement_gets_no_flags…[plain]…::test_statement_using_multiple_features_gets_all_flags…[several features get every flag]…::test_alter_memory_embeddings_gets_nlp_flag_without_naming_the_func…[memory_embeddings ALTER without the function]…::test_alter_table_without_nlp_columns_gets_no_nlp_flag…[other table ALTER gets no nlp flag]test_injectable_identifiers.py::test_catches_pascalcase_handletest_an_identifier_shape_that_semantic_recall_misses_is_injected[PascalCase handle]…::test_catches_snake_case_setting…[snake_case setting]…::test_catches_zero_padded_test_id…[five-digit test id]…::test_catches_stid…[STID]…::test_catches_file_line…[file and line]Compatibility, rollout and rollback
Tests
The five files pass: 71 cases, the 64 before, four split out of two-assertion functions, the seven-digit id and the two length-guard rows.
Coverage: run alone, each file executes the same lines and branches of the module it tests as it did before the change, measured again at the head. I compared the coverage JSON of each file on
mainand on this branch:pytest --cov=<module> --cov-branch <file>.Mutation testing used cosmic-ray, locally only and not added to CI. Each module was mutated, and its test file run against each mutant. Mutants on lines the file never executes survive both versions alike, so they were marked skipped for both. The same mutants ran before and after, and no kill was lost. The seven new kills in
identifiers.pyare in the injection loop and its length and stop-word guard (lines 237-250). Every row runs that loop, but only the seven-digit row's assertion depends on it, since every other row's identifier is also found by another path, before the loop or after it; the four inlemmatize.pyare the-edand-slength guards (lines 23 and 39):server/memory/domain/lemmatize.py(test_lemmatize.py)server/memory/app/extract/keys.py(test_entity_stable_keys.py)server/memory/domain/retrieval_calibration.py(test_identifier_grounding.py)server/memory/app/ask/identifiers.py(test_injectable_identifiers.py)server/core/schema/migrate.py(test_migrate_settings.py)AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. The author checked the case counts, coverage and mutation scores before and after.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no merged migration is edited.frontend/changed.docs/describe the system as it now is.git commit -s).🤖 Generated with Claude Code