Skip to content

Commit ea2ecfc

Browse files
Normalize relation case when combining license expressions
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
1 parent 2efada2 commit ea2ecfc

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/license_expression/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1825,5 +1825,5 @@ def combine_expressions(
18251825
if len(expressions) == 1:
18261826
return expressions[0]
18271827

1828-
relation = {"AND": licensing.AND, "OR": licensing.OR}[relation]
1828+
relation = {"AND": licensing.AND, "OR": licensing.OR}[relation.upper()]
18291829
return relation(*expressions)

tests/test_license_expression.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,3 +2640,9 @@ def test_combine_expressions_with_duplicated_elements(self):
26402640

26412641
def test_combine_expressions_with_or_relationship(self):
26422642
assert str(combine_expressions(["mit", "apache-2.0"], "OR")) == "mit OR apache-2.0"
2643+
2644+
2645+
def test_combine_expressions_accepts_case_insensitive_relations():
2646+
for relation in ("and", "And", "AND", "or", "Or", "OR"):
2647+
result = combine_expressions(["mit", "apache-2.0"], relation=relation)
2648+
assert str(result) == f"mit {relation.upper()} apache-2.0"

0 commit comments

Comments
 (0)