Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ItemsCount to raise ValueError #203

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading