From 054ba79e86b6029aaaa12c140da79141630b2586 Mon Sep 17 00:00:00 2001 From: Aryaz Eghbali Date: Tue, 23 Jan 2024 14:55:12 +0100 Subject: [PATCH 1/2] Test that ItemsCount does not raise ValueError --- tests/test_utils/test_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_utils/test_utils.py b/tests/test_utils/test_utils.py index 9cf1966..cd30ccc 100644 --- a/tests/test_utils/test_utils.py +++ b/tests/test_utils/test_utils.py @@ -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" From bb23f31266ffeeb25101fea3c7056f8359b8e528 Mon Sep 17 00:00:00 2001 From: Aryaz Eghbali Date: Tue, 23 Jan 2024 14:57:15 +0100 Subject: [PATCH 2/2] Fixed ItemsCount to raise ValueError --- sumy/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sumy/utils.py b/sumy/utils.py index 7d0fc92..5eb8e32 100644 --- a/sumy/utils.py +++ b/sumy/utils.py @@ -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("" % self._value)