mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Refactor testing setup (#220)
* Refactor tox and travis config files Separates flake8 and isort into separate tox tasks Tie flake8 and isort to specific python version so they only run once on Travis Add python3.7 to tested python versions * Requires newer Xenial base * Running Xenial on Travis requires sudo Move coveralls submission to travis config to avoid triggering during local runs. * Require all tests to be run Clean up test generation code form test_fi.py Perform coverage measurement of tests Fail tox if coverage of tests directory isn't at 100% * Further Tox refactoring Measure project coverage explicitly instead of omitting non-project files from reporting Add branch measurement to coverage Only report to coveralls if a .coverage result file exists Make dependencies for each testenv explict and only include requried deps * Small readme update to trigger travis Add overly brief message about installing and running tox * Fix unescaped flake8 violations Unescaped \w -> \\w and \e to \\e in regex patterns found with updated flake8
This commit is contained in:
committed by
Ernesto Rodriguez Ortiz
parent
c606fd54e8
commit
5c9bce19e4
@@ -16,7 +16,6 @@
|
||||
|
||||
from __future__ import division, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
from unittest import TestCase
|
||||
|
||||
from num2words import num2words
|
||||
@@ -32,50 +31,6 @@ def n2f(*args, **kwargs):
|
||||
return num2words(lang='fi', *args, **kwargs)
|
||||
|
||||
|
||||
def create_test(number, to):
|
||||
return (
|
||||
"# %s\n" % num2words(number, lang='en') +
|
||||
"self.assertEqual(\n" +
|
||||
' tuple(n2f(%s, to="%s", case=c) for c in CASES),\n' %
|
||||
(number, to) +
|
||||
# grammatical
|
||||
' ("%s", "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c) for c in CASES[0:3]) +
|
||||
# internal locative
|
||||
' "%s", "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c) for c in CASES[3:6]) +
|
||||
# external locative
|
||||
' "%s", "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c) for c in CASES[6:9]) +
|
||||
# essive
|
||||
' "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c) for c in CASES[9:11]) +
|
||||
# rare
|
||||
' "%s", "%s", "%s")\n' %
|
||||
tuple(n2f(number, to=to, case=c) for c in CASES[11:14]) +
|
||||
")\n" +
|
||||
"self.assertEqual(\n" +
|
||||
' tuple(n2f(%s, to="%s", case=c, plural=True) for c in CASES),\n' %
|
||||
(number, to) +
|
||||
# grammatical
|
||||
' ("%s", "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c, plural=True) for c in CASES[0:3]) +
|
||||
# internal locative
|
||||
' "%s", "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c, plural=True) for c in CASES[3:6]) +
|
||||
# external locative
|
||||
' "%s", "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c, plural=True) for c in CASES[6:9]) +
|
||||
# essive
|
||||
' "%s", "%s",\n' %
|
||||
tuple(n2f(number, to=to, case=c, plural=True) for c in CASES[9:11]) +
|
||||
# rare
|
||||
' "%s", "%s", "%s")\n' %
|
||||
tuple(n2f(number, to=to, case=c, plural=True) for c in CASES[11:14]) +
|
||||
")\n"
|
||||
)
|
||||
|
||||
|
||||
class Num2WordsFITest(TestCase):
|
||||
|
||||
def test_low(self):
|
||||
@@ -2804,7 +2759,3 @@ class Num2WordsFITest(TestCase):
|
||||
self.assertEqual(
|
||||
n2f(150, to="currency", currency="FIM", adjective=True),
|
||||
"yksi Suomen markka ja viisikymmentä penniä")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(create_test(int(sys.argv[1]), sys.argv[2]))
|
||||
|
||||
Reference in New Issue
Block a user