From c7755ee6f3c779dad5c648b7aa16e5b6162053cb Mon Sep 17 00:00:00 2001 From: Bryan Anderson Date: Sat, 14 Dec 2024 19:12:52 -0800 Subject: [PATCH] IT: support Decimal class --- num2words/lang_IT.py | 2 +- tests/test_it.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/num2words/lang_IT.py b/num2words/lang_IT.py index 427e6d36..a468a036 100644 --- a/num2words/lang_IT.py +++ b/num2words/lang_IT.py @@ -143,7 +143,7 @@ def big_number_to_cardinal(self, number): def to_cardinal(self, number): if number < 0: string = Num2Word_IT.MINUS_PREFIX_WORD + self.to_cardinal(-number) - elif isinstance(number, float): + elif int(number) != number: string = self.float_to_words(number) elif number < 20: string = CARDINAL_WORDS[int(number)] diff --git a/tests/test_it.py b/tests/test_it.py index 23c081d1..57c9962c 100644 --- a/tests/test_it.py +++ b/tests/test_it.py @@ -65,6 +65,9 @@ def test_negative(self): self.assertEqual("meno " + pos_ord, neg_ord) def test_float_to_cardinal(self): + self.assertEqual( + num2words("3.1415", lang="it"), "tre virgola uno quattro uno cinque" + ) self.assertEqual( num2words(3.1415, lang="it"), "tre virgola uno quattro uno cinque" )