mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 14:52:25 +00:00
Fix the tests after the changes proposed by @10537
Ref: issuer # 10537
This commit is contained in:
@@ -44,8 +44,8 @@ CONVERTER_CLASSES = {
|
|||||||
'fr_CH': lang_FR_CH.Num2Word_FR_CH(),
|
'fr_CH': lang_FR_CH.Num2Word_FR_CH(),
|
||||||
'de': lang_DE.Num2Word_DE(),
|
'de': lang_DE.Num2Word_DE(),
|
||||||
'es': lang_ES.Num2Word_ES(),
|
'es': lang_ES.Num2Word_ES(),
|
||||||
'es_CO': lang_ES_CO.Num2Word_ES_CO,
|
'es_CO': lang_ES_CO.Num2Word_ES_CO(),
|
||||||
'es_VE': lang_ES_VE.Num2Word_ES_VE,
|
'es_VE': lang_ES_VE.Num2Word_ES_VE(),
|
||||||
'id': lang_ID.Num2Word_ID(),
|
'id': lang_ID.Num2Word_ID(),
|
||||||
'lt': lang_LT.Num2Word_LT(),
|
'lt': lang_LT.Num2Word_LT(),
|
||||||
'lv': lang_LV.Num2Word_LV(),
|
'lv': lang_LV.Num2Word_LV(),
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ to_card = n2w.to_cardinal
|
|||||||
to_ord = n2w.to_ordinal
|
to_ord = n2w.to_ordinal
|
||||||
to_ordnum = n2w.to_ordinal_num
|
to_ordnum = n2w.to_ordinal_num
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for val in [1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
for val in [1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
||||||
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
||||||
|
|||||||
@@ -19,12 +19,7 @@ from unittest import TestCase
|
|||||||
|
|
||||||
from num2words import num2words
|
from num2words import num2words
|
||||||
|
|
||||||
|
TEST_CASES_CARDINAL = (
|
||||||
class Num2WordsESTest(TestCase):
|
|
||||||
|
|
||||||
def test_number(self):
|
|
||||||
|
|
||||||
test_cases = (
|
|
||||||
(1, 'uno'),
|
(1, 'uno'),
|
||||||
(2, 'dos'),
|
(2, 'dos'),
|
||||||
(3, 'tres'),
|
(3, 'tres'),
|
||||||
@@ -35,54 +30,49 @@ class Num2WordsESTest(TestCase):
|
|||||||
(20, 'veinte'),
|
(20, 'veinte'),
|
||||||
(21, 'veintiuno'),
|
(21, 'veintiuno'),
|
||||||
(26, 'veintiséis'),
|
(26, 'veintiséis'),
|
||||||
(28, 'vientiocho'),
|
(28, 'veintiocho'),
|
||||||
(30, 'treinta'),
|
(30, 'treinta'),
|
||||||
(31, 'treinta y uno'),
|
(31, 'treinta y uno'),
|
||||||
(40, 'treinta y dos'),
|
(40, 'cuarenta'),
|
||||||
(43, 'treinta y tres'),
|
(44, 'cuarenta y cuatro'),
|
||||||
(50, 'cincuenta'),
|
(50, 'cincuenta'),
|
||||||
(55, 'cincuenta y cinco'),
|
(55, 'cincuenta y cinco'),
|
||||||
(60, 'secenta'),
|
(60, 'sesenta'),
|
||||||
(67, 'secenta y siete'),
|
(67, 'sesenta y siete'),
|
||||||
(70, 'setenta'),
|
(70, 'setenta'),
|
||||||
(79, 'setenta y nueve'),
|
(79, 'setenta y nueve'),
|
||||||
(100, 'cien'),
|
(100, 'cien'),
|
||||||
(101, 'ciento uno'),
|
(101, 'ciento uno'),
|
||||||
(199, 'ciento noventa y nueve'),
|
(199, 'ciento noventa y nueve'),
|
||||||
(203, 'docientos tres'),
|
(203, 'doscientos tres'),
|
||||||
(287, 'docientos ochenta y siete'),
|
(287, 'doscientos ochenta y siete'),
|
||||||
(300, 'trecientos'),
|
(300, 'trescientos'),
|
||||||
(356, 'trecientos cincuenta y seis'),
|
(356, 'trescientos cincuenta y seis'),
|
||||||
(410, 'cuatrocientos'),
|
(400, 'cuatrocientos'),
|
||||||
(434, 'cuatrocientos treinta y cuatro'),
|
(434, 'cuatrocientos treinta y cuatro'),
|
||||||
(578, 'quinientos setenta y ocho'),
|
(578, 'quinientos setenta y ocho'),
|
||||||
(689, 'seiciento ochenta y nueve'),
|
(689, 'seiscientos ochenta y nueve'),
|
||||||
(729, 'setencientos veintinueve'),
|
(729, 'setecientos veintinueve'),
|
||||||
(894, 'ochocientos noventa y cuatro'),
|
(894, 'ochocientos noventa y cuatro'),
|
||||||
(999, 'novecientos noventa y nueve'),
|
(999, 'novecientos noventa y nueve'),
|
||||||
(1000, 'mil'),
|
(1000, 'mil'),
|
||||||
(1001, 'mil uno'),
|
(1001, 'mil uno'),
|
||||||
(1097, 'mil noventa y siete'),
|
(1097, 'mil noventa y siete'),
|
||||||
(1104, 'mil ciento cuatro'),
|
(1104, 'mil ciento cuatro'),
|
||||||
(1243, 'mil docientos cuarenta y tres'),
|
(1243, 'mil doscientos cuarenta y tres'),
|
||||||
(2385, 'dos mil trecientos ochenta y cinco'),
|
(2385, 'dos mil trescientos ochenta y cinco'),
|
||||||
(3766, 'tresmil setencientos sesenta y seis'),
|
(3766, 'tres mil setecientos sesenta y seis'),
|
||||||
(4196, 'cuatro mil ciento noventa y seis'),
|
(4196, 'cuatro mil ciento noventa y seis'),
|
||||||
(5846, 'cinco mil ochocientos cuarenta y seis'),
|
(5846, 'cinco mil ochocientos cuarenta y seis'),
|
||||||
(6459, 'seis mil cuatrocientos cincuenta y nueve'),
|
(6459, 'seis mil cuatrocientos cincuenta y nueve'),
|
||||||
(7232, 'siete mil docientos treinta y dos'),
|
(7232, 'siete mil doscientos treinta y dos'),
|
||||||
(8569, 'ocho mil quinientos sesenta y nueve'),
|
(8569, 'ocho mil quinientos sesenta y nueve'),
|
||||||
(9539, 'nueve mil quinientos treinta y nueve'),
|
(9539, 'nueve mil quinientos treinta y nueve'),
|
||||||
(1000000, 'un millón'),
|
(1000000, 'un millón'),
|
||||||
(1000001, 'un millón uno'),
|
(1000001, 'un millón uno'),
|
||||||
)
|
)
|
||||||
|
|
||||||
for test in test_cases:
|
TEST_CASES_ORDINAL = (
|
||||||
self.assertEqual(num2words(test[0], lang='es'), test[1])
|
|
||||||
|
|
||||||
def test_ordinal(self):
|
|
||||||
|
|
||||||
test_cases = (
|
|
||||||
(1, 'primero'),
|
(1, 'primero'),
|
||||||
(8, 'octavo'),
|
(8, 'octavo'),
|
||||||
(12, 'décimosegundo'),
|
(12, 'décimosegundo'),
|
||||||
@@ -91,5 +81,15 @@ class Num2WordsESTest(TestCase):
|
|||||||
(100, 'centésimo'),
|
(100, 'centésimo'),
|
||||||
)
|
)
|
||||||
|
|
||||||
for test in test_cases:
|
class Num2WordsESTest(TestCase):
|
||||||
self.assertEqual(num2words(test[0], lang='es', ordinal=True), test[1])
|
|
||||||
|
def test_number(self):
|
||||||
|
for test in TEST_CASES_CARDINAL:
|
||||||
|
self.assertEqual(num2words(test[0], lang='es'), test[1])
|
||||||
|
|
||||||
|
def test_ordinal(self):
|
||||||
|
for test in TEST_CASES_ORDINAL:
|
||||||
|
self.assertEqual(
|
||||||
|
num2words(test[0], lang='es', ordinal=True),
|
||||||
|
test[1]
|
||||||
|
)
|
||||||
|
|||||||
@@ -16,81 +16,19 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
|
||||||
|
|
||||||
from num2words import num2words
|
from num2words import num2words
|
||||||
|
from . import test_es
|
||||||
|
|
||||||
|
|
||||||
class Num2WordsESCOTest(TestCase):
|
class Num2WordsESCOTest(test_es.Num2WordsESTest):
|
||||||
|
|
||||||
def test_number(self):
|
def test_number(self):
|
||||||
|
for test in test_es.TEST_CASES_CARDINAL:
|
||||||
test_cases = (
|
|
||||||
(1, 'uno'),
|
|
||||||
(2, 'dos'),
|
|
||||||
(3, 'tres'),
|
|
||||||
(11, 'once'),
|
|
||||||
(12, 'doce'),
|
|
||||||
(16, 'dieciseis'),
|
|
||||||
(19, 'diecinueve'),
|
|
||||||
(20, 'veinte'),
|
|
||||||
(21, 'veintiuno'),
|
|
||||||
(26, 'veintiséis'),
|
|
||||||
(28, 'vientiocho'),
|
|
||||||
(30, 'treinta'),
|
|
||||||
(31, 'treinta y uno'),
|
|
||||||
(40, 'treinta y dos'),
|
|
||||||
(43, 'treinta y tres'),
|
|
||||||
(50, 'cincuenta'),
|
|
||||||
(55, 'cincuenta y cinco'),
|
|
||||||
(60, 'secenta'),
|
|
||||||
(67, 'secenta y siete'),
|
|
||||||
(70, 'setenta'),
|
|
||||||
(79, 'setenta y nueve'),
|
|
||||||
(100, 'cien'),
|
|
||||||
(101, 'ciento uno'),
|
|
||||||
(199, 'ciento noventa y nueve'),
|
|
||||||
(203, 'docientos tres'),
|
|
||||||
(287, 'docientos ochenta y siete'),
|
|
||||||
(300, 'trecientos'),
|
|
||||||
(356, 'trecientos cincuenta y seis'),
|
|
||||||
(410, 'cuatrocientos'),
|
|
||||||
(434, 'cuatrocientos treinta y cuatro'),
|
|
||||||
(578, 'quinientos setenta y ocho'),
|
|
||||||
(689, 'seiciento ochenta y nueve'),
|
|
||||||
(729, 'setencientos veintinueve'),
|
|
||||||
(894, 'ochocientos noventa y cuatro'),
|
|
||||||
(999, 'novecientos noventa y nueve'),
|
|
||||||
(1000, 'mil'),
|
|
||||||
(1001, 'mil uno'),
|
|
||||||
(1097, 'mil noventa y siete'),
|
|
||||||
(1104, 'mil ciento cuatro'),
|
|
||||||
(1243, 'mil docientos cuarenta y tres'),
|
|
||||||
(2385, 'dos mil trecientos ochenta y cinco'),
|
|
||||||
(3766, 'tresmil setencientos sesenta y seis'),
|
|
||||||
(4196, 'cuatromil ciento noventa y seis'),
|
|
||||||
(5846, 'cinco mil ochocientos cuarenta y seis'),
|
|
||||||
(6459, 'seis mil cuatrocientos cincuenta y nueve'),
|
|
||||||
(7232, 'siete mil docientos treinta y dos'),
|
|
||||||
(8569, 'ocho mil quinientos sesenta y nueve'),
|
|
||||||
(9539, 'nueve mil quinientos treinta y nueve'),
|
|
||||||
(1000000, 'un millón'),
|
|
||||||
(1000001, 'un millón uno'),
|
|
||||||
)
|
|
||||||
|
|
||||||
for test in test_cases:
|
|
||||||
self.assertEqual(num2words(test[0], lang='es_CO'), test[1])
|
self.assertEqual(num2words(test[0], lang='es_CO'), test[1])
|
||||||
|
|
||||||
def test_ordinal(self):
|
def test_ordinal(self):
|
||||||
|
for test in test_es.TEST_CASES_ORDINAL:
|
||||||
test_cases = (
|
self.assertEqual(
|
||||||
(1, 'primero'),
|
num2words(test[0], lang='es_CO', ordinal=True),
|
||||||
(8, 'octavo'),
|
test[1]
|
||||||
(12, 'décimo segundo'),
|
|
||||||
(14, 'décimo cuarto'),
|
|
||||||
(28, 'vigésimo octavo'),
|
|
||||||
(100, 'centésimo'),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for test in test_cases:
|
|
||||||
self.assertEqual(num2words(test[0], lang='es_CO', ordinal=True), test[1])
|
|
||||||
|
|||||||
@@ -16,82 +16,19 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
|
||||||
|
|
||||||
from num2words import num2words
|
from num2words import num2words
|
||||||
|
from . import test_es
|
||||||
|
|
||||||
|
|
||||||
class Num2WordsESVETest(TestCase):
|
class Num2WordsESVETest(test_es.Num2WordsESTest):
|
||||||
|
|
||||||
def test_number(self):
|
def test_number(self):
|
||||||
|
for test in test_es.TEST_CASES_CARDINAL:
|
||||||
test_cases = (
|
|
||||||
(1, 'uno'),
|
|
||||||
(2, 'dos'),
|
|
||||||
(3, 'tres'),
|
|
||||||
(11, 'once'),
|
|
||||||
(12, 'doce'),
|
|
||||||
(16, 'dieciseis'),
|
|
||||||
(19, 'diecinueve'),
|
|
||||||
(20, 'veinte'),
|
|
||||||
(21, 'veintiuno'),
|
|
||||||
(26, 'veintiséis'),
|
|
||||||
(28, 'vientiocho'),
|
|
||||||
(30, 'treinta'),
|
|
||||||
(31, 'treinta y uno'),
|
|
||||||
(40, 'treinta y dos'),
|
|
||||||
(43, 'treinta y tres'),
|
|
||||||
(50, 'cincuenta'),
|
|
||||||
(55, 'cincuenta y cinco'),
|
|
||||||
(60, 'secenta'),
|
|
||||||
(67, 'secenta y siete'),
|
|
||||||
(70, 'setenta'),
|
|
||||||
(79, 'setenta y nueve'),
|
|
||||||
(100, 'cien'),
|
|
||||||
(101, 'ciento uno'),
|
|
||||||
(199, 'ciento noventa y nueve'),
|
|
||||||
(203, 'docientos tres'),
|
|
||||||
(287, 'docientos ochenta y siete'),
|
|
||||||
(300, 'trecientos'),
|
|
||||||
(356, 'trecientos cincuenta y seis'),
|
|
||||||
(410, 'cuatrocientos'),
|
|
||||||
(434, 'cuatrocientos treinta y cuatro'),
|
|
||||||
(578, 'quinientos setenta y ocho'),
|
|
||||||
(689, 'seiciento ochenta y nueve'),
|
|
||||||
(729, 'setencientos veintinueve'),
|
|
||||||
(894, 'ochocientos noventa y cuatro'),
|
|
||||||
(999, 'novecientos noventa y nueve'),
|
|
||||||
(1000, 'mil'),
|
|
||||||
(1001, 'mil uno'),
|
|
||||||
(1097, 'mil noventa y siete'),
|
|
||||||
(1104, 'mil ciento cuatro'),
|
|
||||||
(1243, 'mil docientos cuarenta y tres'),
|
|
||||||
(2385, 'dos mil trecientos ochenta y cinco'),
|
|
||||||
(3766, 'tresmil setencientos sesenta y seis'),
|
|
||||||
(4196, 'cuatromil ciento noventa y seis'),
|
|
||||||
(5846, 'cinco mil ochocientos cuarenta y seis'),
|
|
||||||
(6459, 'seis mil cuatrocientos cincuenta y nueve'),
|
|
||||||
(7232, 'siete mil docientos treinta y dos'),
|
|
||||||
(8569, 'ocho mil quinientos sesenta y nueve'),
|
|
||||||
(9539, 'nueve mil quinientos treinta y nueve'),
|
|
||||||
(1000000, 'un millón'),
|
|
||||||
(1000001, 'un millón uno'),
|
|
||||||
)
|
|
||||||
|
|
||||||
for test in test_cases:
|
|
||||||
self.assertEqual(num2words(test[0], lang='es_VE'), test[1])
|
self.assertEqual(num2words(test[0], lang='es_VE'), test[1])
|
||||||
|
|
||||||
def test_ordinal(self):
|
def test_ordinal(self):
|
||||||
|
for test in test_es.TEST_CASES_ORDINAL:
|
||||||
test_cases = (
|
self.assertEqual(
|
||||||
(1, 'primero'),
|
num2words(test[0], lang='es_VE', ordinal=True),
|
||||||
(8, 'octavo'),
|
test[1]
|
||||||
(12, 'décimo segundo'),
|
|
||||||
(14, 'décimo cuarto'),
|
|
||||||
(28, 'vigésimo octavo'),
|
|
||||||
(100, 'centésimo'),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for test in test_cases:
|
|
||||||
self.assertEqual(num2words(test[0], lang='es_VE', ordinal=True), test[1])
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user