Skip to content

Commit e4e6456

Browse files
committed
Fix masked license validation test names (#5257)
Signed-off-by: harishwargad <harishwargad@gmail.com>
1 parent 3c532f0 commit e4e6456

5 files changed

Lines changed: 27 additions & 0 deletions

File tree

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,4 @@ The following organizations or individuals have contributed to ScanCode:
108108
- Yash Sharma @yasharmaster
109109
- Yunus Rahbar @yns88
110110
- Stefano Zacchiroli @zacchiro
111+
- Harish Wargad @harishwargad

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Next release
88
``licensedcode-data``.
99
https://github.com/aboutcode-org/scancode-toolkit/pull/5056
1010

11+
- Ensure each license rule has a unique generated validation
12+
test name, by renaming colliding rule files and adding a
13+
regression test to prevent rule name collisions.
14+
https://github.com/aboutcode-org/scancode-toolkit/issues/5257
15+
16+
1117
v33.0.0rc1 - 2026-05-14
1218
------------------------
1319

File renamed without changes.
File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from collections import defaultdict
2+
from pathlib import Path
3+
from commoncode.text import python_safe_name
4+
5+
RULES_DATA_DIR = Path(__file__).parents[2] / "src" / "licensedcode" / "data" / "rules"
6+
7+
def test_rule_file_names_generate_unique_python_names():
8+
rule_names_by_python_name = defaultdict(list)
9+
10+
for rule_file in RULES_DATA_DIR.glob("*.RULE"):
11+
python_name = python_safe_name(rule_file.name)
12+
rule_names_by_python_name[python_name].append(rule_file.name)
13+
14+
duplicate_names = {
15+
python_name: sorted(rule_names)
16+
for python_name, rule_names in rule_names_by_python_name.items()
17+
if len(rule_names) > 1
18+
}
19+
20+
assert not duplicate_names, duplicate_names

0 commit comments

Comments
 (0)