mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Merge pull request #283 from williamjmorenor/base
Add more tests to base.py
This commit is contained in:
@@ -139,7 +139,7 @@ class Num2Word_Base(object):
|
|||||||
def to_cardinal_float(self, value):
|
def to_cardinal_float(self, value):
|
||||||
try:
|
try:
|
||||||
float(value) == value
|
float(value) == value
|
||||||
except (ValueError, TypeError, AssertionError):
|
except (ValueError, TypeError, AssertionError, AttributeError):
|
||||||
raise TypeError(self.errmsg_nonnum % value)
|
raise TypeError(self.errmsg_nonnum % value)
|
||||||
|
|
||||||
pre, post = self.float2tuple(float(value))
|
pre, post = self.float2tuple(float(value))
|
||||||
|
|||||||
@@ -32,3 +32,29 @@ class Num2WordBaseTest(TestCase):
|
|||||||
def test_to_currency_not_implemented(self):
|
def test_to_currency_not_implemented(self):
|
||||||
with self.assertRaises(NotImplementedError):
|
with self.assertRaises(NotImplementedError):
|
||||||
self.base.to_currency(Decimal('1.00'), currency='EUR')
|
self.base.to_currency(Decimal('1.00'), currency='EUR')
|
||||||
|
|
||||||
|
def test_error_to_cardinal_float(self):
|
||||||
|
from num2words.base import Num2Word_Base
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
Num2Word_Base.to_cardinal_float(9)
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
Num2Word_Base.to_cardinal_float("a")
|
||||||
|
|
||||||
|
def test_error_merge(self):
|
||||||
|
from num2words.base import Num2Word_Base
|
||||||
|
self.base = Num2Word_Base()
|
||||||
|
with self.assertRaises(NotImplementedError):
|
||||||
|
self.base.merge(2, 3)
|
||||||
|
|
||||||
|
def test_is_title(self):
|
||||||
|
from num2words.base import Num2Word_Base
|
||||||
|
self.base = Num2Word_Base()
|
||||||
|
self.assertEqual(
|
||||||
|
self.base.title("one"),
|
||||||
|
"one"
|
||||||
|
)
|
||||||
|
self.base.is_title = True
|
||||||
|
self.assertEqual(
|
||||||
|
self.base.title("one"),
|
||||||
|
"One"
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user