Fix masked license validation test names (#5257) - #5263
Open
harishwargad wants to merge 2 commits into
Open
Conversation
Signed-off-by: harishwargad <harishwargad@gmail.com>
Signed-off-by: Ayan Sinha Mahapatra <asmahapatra@aboutcode.org>
AyanSinhaMahapatra
requested changes
Aug 28, 2026
AyanSinhaMahapatra
left a comment
Member
There was a problem hiding this comment.
Thanks @harishwargad see comments for changes
| from pathlib import Path | ||
| from commoncode.text import python_safe_name | ||
|
|
||
| RULES_DATA_DIR = Path(__file__).parents[2] / "src" / "licensedcode" / "data" / "rules" |
Member
There was a problem hiding this comment.
Could you reuse this, rules_data_dir is defined here: https://github.com/aboutcode-org/scancode-toolkit/blob/develop/src/licensedcode/models.py#L88
| @@ -0,0 +1,20 @@ | |||
| from collections import defaultdict | |||
Member
There was a problem hiding this comment.
I like more the rule renames at https://github.com/aboutcode-org/scancode-toolkit/pull/5258/changes
cnri-python-1.6_1.RULE -> cnri-python-1.6_19.RULE
proprietary_10_alt.RULE -> proprietary_155.RULE
| if len(rule_names) > 1 | ||
| } | ||
|
|
||
| assert not duplicate_names, duplicate_names |
Member
There was a problem hiding this comment.
can you directly use the assert on the list comprehension?
6 tasks
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.
Fixes #5257
Summary
This PR addresses issue #5257 where license rule file pairs mapped to the exact same dynamically generated Python validation test method names (e.g.,
cnri-python-1.6.1.RULEandcnri-python-1.6_1.RULEboth producingcnri_python_1_6_1_rule), causing tests to overwrite/mask each other during dynamic test generation.Building on the initial test setup from stale PR #5258, this PR completes the rule file renames.
Changes Made
cnri-python-1.6_1.RULE->cnri-python-1.6-v1.RULEandproprietary_10.RULE->proprietary_10_alt.RULEusinggit mvso generated safe Python method names are unique.tests/licensedcode/test_rule_file_names.pyto ensure all rule file names generate unique safe Python method names in the future.CHANGELOG.rstandAUTHORS.rst.Tasks
Run tests locally to check for errors.
Signed-off-by: @harishwargad