From 424cf9fda8ad5257012da442a549d6c6c76bd1e4 Mon Sep 17 00:00:00 2001 From: Temoctzin Date: Sat, 13 Oct 2018 18:25:58 -0500 Subject: [PATCH] feat(Num2Word_EU): add MX to CURRENCY_FORMS (#187) * lang_EU: add MX to CURRENCY_FORMS and CURRENCY_ADJETIVES --- num2words/lang_EU.py | 2 ++ tests/test_en.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/num2words/lang_EU.py b/num2words/lang_EU.py index b46818d..fc804f3 100644 --- a/num2words/lang_EU.py +++ b/num2words/lang_EU.py @@ -40,6 +40,7 @@ class Num2Word_EU(Num2Word_Base): 'SEK': (('krona', 'kronor'), ('öre', 'öre')), 'NOK': (('krone', 'kroner'), ('øre', 'øre')), 'PLN': (('zloty', 'zlotys', 'zlotu'), ('grosz', 'groszy')), + 'MXN': (('peso', 'pesos'), GENERIC_CENTS), } CURRENCY_ADJECTIVES = { @@ -49,6 +50,7 @@ class Num2Word_EU(Num2Word_Base): 'USD': 'US', 'RUB': 'Russian', 'NOK': 'Norwegian', + 'MXN': 'Mexican', } GIGA_SUFFIX = "illiard" diff --git a/tests/test_en.py b/tests/test_en.py index 4b099cb..b3b2bc0 100644 --- a/tests/test_en.py +++ b/tests/test_en.py @@ -97,6 +97,30 @@ class Num2WordsENTest(TestCase): 'four thousand, seven hundred and seventy-eight dollars and' ' zero cents') + self.assertEqual( + num2words('1.1', lang='en', to='currency', seperator=' and', + cents=True, currency='MXN'), + "one peso and ten cents" + ) + + self.assertEqual( + num2words('158.3', lang='en', to='currency', seperator=' and', + cents=True, currency='MXN'), + "one hundred and fifty-eight pesos and thirty cents" + ) + + self.assertEqual( + num2words('2000.00', lang='en', to='currency', seperator=' and', + cents=True, currency='MXN'), + "two thousand pesos and zero cents" + ) + + self.assertEqual( + num2words('4.01', lang='en', to='currency', seperator=' and', + cents=True, currency='MXN'), + "four pesos and one cent" + ) + def test_to_year(self): # issue 141 # "e2 e2"