Long form for currency name is optional. Currency name rendering in e… (#133)

* Long form for currency name is optional. Currency name rendering in english.

* Missing encoding header.
This commit is contained in:
Mārtiņš Šulcs
2017-11-06 00:59:25 +02:00
committed by Ernesto Rodriguez Ortiz
parent ee9f767b06
commit 5a131fedc6
8 changed files with 146 additions and 25 deletions

View File

@@ -29,3 +29,33 @@ class Num2WordsENTest(TestCase):
self.assertEqual(num2words(12.51), "twelve point five one")
self.assertEqual(num2words(12.53), "twelve point five three")
self.assertEqual(num2words(12.59), "twelve point five nine")
def test_to_currency(self):
self.assertEqual(
num2words('38.4', lang='en', to='currency', seperator=' and',
cents=False, currency='USD'),
"thirty-eight dollars and 40 cents"
)
self.assertEqual(
num2words('0', lang='en', to='currency', seperator=' and',
cents=False, currency='USD'),
"zero dollars and 00 cents"
)
self.assertEqual(
num2words('1.01', lang='en', to='currency', seperator=' and',
cents=True, currency='USD'),
"one dollar and one cent"
)
self.assertEqual(
num2words('4778.00', lang='en', to='currency', seperator=' and',
cents=True, currency='USD', prefix=True),
'four thousand, seven hundred and seventy-eight US dollars'
' and zero cents')
self.assertEqual(
num2words('4778.00', lang='en', to='currency', seperator=' and',
cents=True, currency='USD'),
'four thousand, seven hundred and seventy-eight dollars and'
' zero cents')