Skip to content

Commit

Permalink
Merge pull request #283 from williamjmorenor/base
Browse files Browse the repository at this point in the history
Add more tests to base.py
  • Loading branch information
erozqba committed Dec 31, 2019
2 parents ff6ff0e + af7882a commit 5fe8815
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion num2words/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def float2tuple(self, value):
def to_cardinal_float(self, value):
try:
float(value) == value
except (ValueError, TypeError, AssertionError):
except (ValueError, TypeError, AssertionError, AttributeError):
raise TypeError(self.errmsg_nonnum % value)

pre, post = self.float2tuple(float(value))
Expand Down
26 changes: 26 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,29 @@ def setUpClass(cls):
def test_to_currency_not_implemented(self):
with self.assertRaises(NotImplementedError):
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"
)

0 comments on commit 5fe8815

Please sign in to comment.