Skip to content

Commit

Permalink
IT: support Decimal class
Browse files Browse the repository at this point in the history
  • Loading branch information
bryananderson committed Dec 17, 2024
1 parent 0df2a0e commit 8e6e017
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Binary file added .coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion num2words/lang_IT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
10 changes: 7 additions & 3 deletions tests/test_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ 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"
)
Expand Down Expand Up @@ -264,10 +268,10 @@ def test_nth_big(self):
)

def test_with_floats(self):
self.assertAlmostEqual(
num2words(1.0, lang="it"), "uno virgola zero"
self.assertEqual(
num2words(1.0, lang="it"), "uno"
)
self.assertAlmostEqual(
self.assertEqual(
num2words(1.1, lang="it"), "uno virgola uno"
)

Expand Down

0 comments on commit 8e6e017

Please sign in to comment.