Skip to content

Commit 68ab63d

Browse files
committed
add test for 3-seq and extra-words-spans
Signed-off-by: Alok Kumar <[email protected]>
1 parent 060fd63 commit 68ab63d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/licensedcode/detection.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ def is_correct_detection(license_matches):
10951095
]
10961096

10971097
return (
1098-
all(matcher in ("1-hash", "1-spdx-id", "2-aho") for matcher in matchers)
1098+
all(matcher in ("1-hash", "1-spdx-id", "2-aho", "3-seq") for matcher in matchers)
10991099
and all(is_match_coverage_perfect)
11001100
)
11011101

@@ -1156,6 +1156,17 @@ def has_extra_words(license_matches):
11561156
)
11571157

11581158

1159+
def has_extra_words_spans(license_matches):
1160+
"""
1161+
Return True if all of the matches rules in ``license_matches`` (a list of LicenseMatch)
1162+
has `extra_phrase` marker and also have matcher `3-seq`.
1163+
"""
1164+
return all(
1165+
match.matcher == '3-seq' and match.rule.extra_phrase_spans
1166+
for match in license_matches
1167+
)
1168+
1169+
11591170
def has_low_rule_relevance(license_matches):
11601171
"""
11611172
Return True if all on the matches in ``license_matches`` List of LicenseMatch

tests/licensedcode/test_detection_validate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from licensedcode import cache
1919
from licensedcode import models
2020
from licensedcode.detection import is_correct_detection
21+
from licensedcode.detection import has_extra_words_spans
2122
from licensedcode.models import licenses_data_dir
2223
from licensedcode.models import rules_data_dir
2324
from licensedcode.models import License
@@ -99,7 +100,7 @@ def check_rule_or_license_can_be_detected_exactly(licensish):
99100
assert results == expected
100101

101102
icm = is_correct_detection(matches)
102-
if not icm:
103+
if not icm and not has_extra_words_spans(matches):
103104
expected.append(f'file://{licensish.rule_file()}')
104105
assert results == expected
105106

0 commit comments

Comments
 (0)