From c10ce52b3c60c3b0ccd5da46e1d2366cf3d7a767 Mon Sep 17 00:00:00 2001 From: Marlon Rodriguez Garcia Date: Tue, 19 Nov 2024 14:36:05 -0500 Subject: [PATCH] Add test to improve coverage --- num2words/base.py | 2 +- tests/test_base.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/num2words/base.py b/num2words/base.py index 243045ff..4d833641 100644 --- a/num2words/base.py +++ b/num2words/base.py @@ -111,7 +111,7 @@ def to_cardinal(self, value): value = abs(value) out = "%s " % self.negword.strip() - if value >= self.MAXVAL: + if hasattr(self, 'MAXVAL') and value >= self.MAXVAL: raise OverflowError(self.errmsg_toobig % (value, self.MAXVAL)) val = self.splitnum(value) diff --git a/tests/test_base.py b/tests/test_base.py index efa1bc81..e05bc7df 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -62,3 +62,16 @@ def test_is_title(self): self.base.title("one"), "one" ) + + def test_set_high_numwords_not_implemented(self): + with self.assertRaises(NotImplementedError): + self.base.set_high_numwords() + + def test_to_ordinal(self): + from num2words.base import Num2Word_Base + self.base = Num2Word_Base() + self.assertEqual(self.base.to_ordinal(1), "1st") + self.assertEqual(self.base.to_ordinal(11), "11th") + self.assertEqual(self.base.to_ordinal(21), "21st") + self.assertEqual(self.base.to_ordinal(100), "100th") + self.assertEqual(self.base.to_ordinal(123), "123rd")