Fix lang_IT handling of floats (#143)

`n % 1 != 0` is not a valid test for float:

In []: 1.1 % 1 == 0
Out[]: False

but:

In []: 1.0 % 1 == 0
Out[]: True

hence it's really necessary to explicitly test for type in this case.
This commit is contained in:
Carli Samuele
2017-12-04 23:16:06 +01:00
committed by Ernesto Rodriguez Ortiz
parent 8ffdc5e49d
commit efce631944
2 changed files with 9 additions and 2 deletions

View File

@@ -22,7 +22,6 @@ from num2words import num2words
class Num2WordsITTest(TestCase):
maxDiff = None
def test_negative(self):
@@ -225,3 +224,11 @@ class Num2WordsITTest(TestCase):
"novecentouno miliardi, duecentotrentaquattro milioni e "
"cinquecentosessantasettemilaottocentonovantesimo"
)
def test_with_decimals(self):
self.assertAlmostEqual(
num2words(1.0, lang="it"), "uno virgola zero"
)
self.assertAlmostEqual(
num2words(1.1, lang="it"), "uno virgola uno"
)