Skip to content

Commit

Permalink
Portuguese: add more currencies and test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bryananderson committed Jan 16, 2025
1 parent 7df3db9 commit b6a3ec5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions num2words/lang_PT.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ class Num2Word_PT(Num2Word_EU):
CURRENCY_FORMS = {
'AUD': (DOLLAR, CENTS),
'CAD': (DOLLAR, CENTS),
'NZD': (DOLLAR, CENTS),
'HKD': (DOLLAR, CENTS),
'EUR': (('euro', 'euros'), CENTS),
'GBP': (('libra', 'libras'), ('péni', 'pence')),
'CNY': (('yuan', 'yuans'), ('fen', 'fen')),
'JPY': (('iene', 'ienes'), ('sen', 'sen')),
'INR': (('rupia', 'rupias'), ('paisa', 'paisas')),
'RUB': (('rublo', 'rublos'), ('copeque', 'copeques')),
'KRW': (('won', 'wons'), ('jeon', 'jeons')),
'MXN': (('peso', 'pesos'), ('centavo', 'centavos')),
'USD': (DOLLAR, CENTS),
}

Expand Down
20 changes: 20 additions & 0 deletions tests/test_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,26 @@ def test_currency_integer(self):
'um dólar')
self.assertEqual(self.n2w.to_currency(1.50, currency='USD'),
'um dólar e cinquenta cêntimos')
self.assertEqual(self.n2w.to_currency(1.50, currency='CAD'),
'um dólar e cinquenta cêntimos')
self.assertEqual(self.n2w.to_currency(1.50, currency='AUD'),
'um dólar e cinquenta cêntimos')
self.assertEqual(self.n2w.to_currency(1.50, currency='NZD'),
'um dólar e cinquenta cêntimos')
self.assertEqual(self.n2w.to_currency(1.50, currency='HKD'),
'um dólar e cinquenta cêntimos')
self.assertEqual(self.n2w.to_currency(1.50, currency='CNY'),
'um yuan e cinquenta fen')
self.assertEqual(self.n2w.to_currency(1.50, currency='JPY'),
'um iene e cinquenta sen')
self.assertEqual(self.n2w.to_currency(1.50, currency='INR'),
'um rupia e cinquenta paisas')
self.assertEqual(self.n2w.to_currency(1.50, currency='RUB'),
'um rublo e cinquenta copeques')
self.assertEqual(self.n2w.to_currency(1.50, currency='KRW'),
'um won e cinquenta jeons')
self.assertEqual(self.n2w.to_currency(1.50, currency='MXN'),
'um peso e cinquenta centavos')
with self.assertRaises(NotImplementedError):
self.n2w.to_currency(1.00, currency='CHF')

Expand Down

0 comments on commit b6a3ec5

Please sign in to comment.