Updates accents on céntimos in Spanish (#240)

* Updates accents on céntimos in Spanish

* Update test_es.py

* Update test_es.py

* fix tests

* fix encoding

* Update tox.ini

* Update test_cli.py

* Update test_cli.py

* Update test_cli.py

* Update lang_AR.py

flake-8 compliant

* Update test_cli.py

flake8 compliant

* Update test_cli.py

* Update test_cli.py
This commit is contained in:
Alvaro
2019-02-12 19:59:46 +01:00
committed by Ernesto Rodriguez Ortiz
parent aa9b882fe6
commit eef5b03593
5 changed files with 51 additions and 46 deletions

View File

@@ -188,11 +188,11 @@ class Num2Word_AR(object):
ones = tens % 10 ones = tens % 10
tens = (tens / 10) - 2 tens = (tens / 10) - 2
if ones > 0: if ones > 0:
if ret_val is not "" and tens < 4: if ret_val != "" and tens < 4:
ret_val += " و " ret_val += " و "
ret_val += self.digit_feminine_status(ones, group_level) ret_val += self.digit_feminine_status(ones, group_level)
if ret_val is not "" and ones != 0: if ret_val != "" and ones != 0:
ret_val += " و " ret_val += " و "
ret_val += self.arabicTens[int(tens)] ret_val += self.arabicTens[int(tens)]
@@ -226,9 +226,9 @@ class Num2Word_AR(object):
self.process_arabic_group(number_to_process, self.process_arabic_group(number_to_process,
group, group,
Decimal(floor(temp_number))) Decimal(floor(temp_number)))
if group_description is not '': if group_description != '':
if group > 0: if group > 0:
if ret_val is not "": if ret_val != "":
ret_val = "{} و {}".format("", ret_val) ret_val = "{} و {}".format("", ret_val)
if number_to_process != 2: if number_to_process != 2:
if number_to_process % 100 != 1: if number_to_process % 100 != 1:
@@ -236,7 +236,7 @@ class Num2Word_AR(object):
ret_val = "{} {}".format( ret_val = "{} {}".format(
self.arabicPluralGroups[group], ret_val) self.arabicPluralGroups[group], ret_val)
else: else:
if ret_val is not "": if ret_val != "":
ret_val = "{} {}".format( ret_val = "{} {}".format(
self.arabicAppendedGroup[group], self.arabicAppendedGroup[group],
ret_val) ret_val)
@@ -250,7 +250,7 @@ class Num2Word_AR(object):
ret_val = "{} {}".format(group_description, ret_val) ret_val = "{} {}".format(group_description, ret_val)
group += 1 group += 1
formatted_number = "" formatted_number = ""
if self.arabicPrefixText is not "": if self.arabicPrefixText != "":
formatted_number += "{} ".format(self.arabicPrefixText) formatted_number += "{} ".format(self.arabicPrefixText)
formatted_number += ret_val formatted_number += ret_val
if self.integer_value != 0: if self.integer_value != 0:
@@ -288,7 +288,7 @@ class Num2Word_AR(object):
elif 11 <= remaining100 <= 99: elif 11 <= remaining100 <= 99:
formatted_number += self.currency_subunit[3] formatted_number += self.currency_subunit[3]
if self.arabicSuffixText is not "": if self.arabicSuffixText != "":
formatted_number += " {}".format(self.arabicSuffixText) formatted_number += " {}".format(self.arabicSuffixText)
return formatted_number return formatted_number
@@ -299,10 +299,10 @@ class Num2Word_AR(object):
return number return number
def set_currency_prefer(self, currency): def set_currency_prefer(self, currency):
if currency is 'EGP': if currency == 'EGP':
self.currency_unit = CURRENCY_EGP[0] self.currency_unit = CURRENCY_EGP[0]
self.currency_subunit = CURRENCY_EGP[1] self.currency_subunit = CURRENCY_EGP[1]
elif currency is 'KWD': elif currency == 'KWD':
self.currency_unit = CURRENCY_KWD[0] self.currency_unit = CURRENCY_KWD[0]
self.currency_subunit = CURRENCY_KWD[1] self.currency_subunit = CURRENCY_KWD[1]
else: else:

View File

@@ -22,10 +22,10 @@ from .lang_EU import Num2Word_EU
class Num2Word_ES(Num2Word_EU): class Num2Word_ES(Num2Word_EU):
CURRENCY_FORMS = { CURRENCY_FORMS = {
'EUR': (('euro', 'euros'), ('centimo', 'centimos')), 'EUR': (('euro', 'euros'), ('céntimo', 'céntimos')),
'ESP': (('peseta', 'pesetas'), ('centimo', 'centimos')), 'ESP': (('peseta', 'pesetas'), ('céntimo', 'céntimos')),
'USD': (('dolar', 'dolares'), ('centavo', 'centavos')), 'USD': (('dolar', 'dólares'), ('centavo', 'centavos')),
'PEN': (('sol', 'soles'), ('centimo', 'centimos')), 'PEN': (('sol', 'soles'), ('céntimo', 'céntimos')),
} }
# //CHECK: Is this sufficient?? # //CHECK: Is this sufficient??

View File

@@ -106,6 +106,7 @@ class CliTestCase(unittest.TestCase):
output = self.cli.run_cmd(150.55, '--lang', 'es', '--to', 'currency') output = self.cli.run_cmd(150.55, '--lang', 'es', '--to', 'currency')
self.assertEqual(output.return_code, 0) self.assertEqual(output.return_code, 0)
self.assertEqual( self.assertEqual(
output.out.strip(), (output.out.decode('utf-8') if hasattr(output.out, 'decode') else
"ciento cincuenta euros con cincuenta y cinco centimos" output.out).strip(),
"ciento cincuenta euros con cincuenta y cinco céntimos"
) )

View File

@@ -112,47 +112,47 @@ TEST_CASES_ORDINAL_NUM = (
) )
TEST_CASES_TO_CURRENCY = ( TEST_CASES_TO_CURRENCY = (
(1.00, 'un euro con cero centimos'), (1.00, 'un euro con cero céntimos'),
(2.00, 'dos euros con cero centimos'), (2.00, 'dos euros con cero céntimos'),
(8.00, 'ocho euros con cero centimos'), (8.00, 'ocho euros con cero céntimos'),
(12.00, 'doce euros con cero centimos'), (12.00, 'doce euros con cero céntimos'),
(21.00, 'veintiun euros con cero centimos'), (21.00, 'veintiun euros con cero céntimos'),
(81.25, 'ochenta y un euros con veinticinco centimos'), (81.25, 'ochenta y un euros con veinticinco céntimos'),
(350.90, 'trescientos cincuenta euros con noventa centimos'), (350.90, 'trescientos cincuenta euros con noventa céntimos'),
(100.00, 'cien euros con cero centimos'), (100.00, 'cien euros con cero céntimos'),
) )
TEST_CASES_TO_CURRENCY_ESP = ( TEST_CASES_TO_CURRENCY_ESP = (
(1.00, 'un peseta con cero centimos'), (1.00, 'un peseta con cero céntimos'),
(2.00, 'dos pesetas con cero centimos'), (2.00, 'dos pesetas con cero céntimos'),
(8.00, 'ocho pesetas con cero centimos'), (8.00, 'ocho pesetas con cero céntimos'),
(12.00, 'doce pesetas con cero centimos'), (12.00, 'doce pesetas con cero céntimos'),
(21.00, 'veintiun pesetas con cero centimos'), (21.00, 'veintiun pesetas con cero céntimos'),
(81.25, 'ochenta y un pesetas con veinticinco centimos'), (81.25, 'ochenta y un pesetas con veinticinco céntimos'),
(350.90, 'trescientos cincuenta pesetas con noventa centimos'), (350.90, 'trescientos cincuenta pesetas con noventa céntimos'),
(100.00, 'cien pesetas con cero centimos'), (100.00, 'cien pesetas con cero céntimos'),
) )
TEST_CASES_TO_CURRENCY_USD = ( TEST_CASES_TO_CURRENCY_USD = (
(1.00, 'un dolar con cero centavos'), (1.00, 'un dolar con cero centavos'),
(2.00, 'dos dolares con cero centavos'), (2.00, 'dos dólares con cero centavos'),
(8.00, 'ocho dolares con cero centavos'), (8.00, 'ocho dólares con cero centavos'),
(12.00, 'doce dolares con cero centavos'), (12.00, 'doce dólares con cero centavos'),
(21.00, 'veintiun dolares con cero centavos'), (21.00, 'veintiun dólares con cero centavos'),
(81.25, 'ochenta y un dolares con veinticinco centavos'), (81.25, 'ochenta y un dólares con veinticinco centavos'),
(350.90, 'trescientos cincuenta dolares con noventa centavos'), (350.90, 'trescientos cincuenta dólares con noventa centavos'),
(100.00, 'cien dolares con cero centavos'), (100.00, 'cien dólares con cero centavos'),
) )
TEST_CASES_TO_CURRENCY_PEN = ( TEST_CASES_TO_CURRENCY_PEN = (
(1.00, 'un sol con cero centimos'), (1.00, 'un sol con cero céntimos'),
(2.00, 'dos soles con cero centimos'), (2.00, 'dos soles con cero céntimos'),
(8.00, 'ocho soles con cero centimos'), (8.00, 'ocho soles con cero céntimos'),
(12.00, 'doce soles con cero centimos'), (12.00, 'doce soles con cero céntimos'),
(21.00, 'veintiun soles con cero centimos'), (21.00, 'veintiun soles con cero céntimos'),
(81.25, 'ochenta y un soles con veinticinco centimos'), (81.25, 'ochenta y un soles con veinticinco céntimos'),
(350.90, 'trescientos cincuenta soles con noventa centimos'), (350.90, 'trescientos cincuenta soles con noventa céntimos'),
(100.00, 'cien soles con cero centimos'), (100.00, 'cien soles con cero céntimos'),
) )

View File

@@ -26,3 +26,7 @@ deps =
delegator.py delegator.py
commands = commands =
isort --check-only --recursive --diff num2words tests isort --check-only --recursive --diff num2words tests
[testenv:py27]
setenv =
PYTHONIOENCODING = UTF-8