Skip to content

Commit

Permalink
Fixed ItemsCount to raise ValueError (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
AryazE authored Jan 23, 2024
1 parent 230feaf commit 0bcec9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sumy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __call__(self, sequence):
elif isinstance(self._value, (int, float)):
return sequence[:int(self._value)]
else:
ValueError("Unsuported value of items count '%s'." % self._value)
raise ValueError("Unsuported value of items count '%s'." % self._value)

def __repr__(self):
return to_string("<ItemsCount: %r>" % self._value)
7 changes: 7 additions & 0 deletions tests/test_utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def test_unsupported_items_count():
count([])


def test_items_count_with_unsupported_init_type():
count = ItemsCount([])

with pytest.raises(ValueError):
count([])


def test_normalize_language_with_alpha_2_code():
assert normalize_language("fr") == "french"
assert normalize_language("zh") == "chinese"
Expand Down

0 comments on commit 0bcec9f

Please sign in to comment.