summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDamien Garaud <damien.garaud@logilab.fr>2012-02-20 10:57:06 +0100
committerDamien Garaud <damien.garaud@logilab.fr>2012-02-20 10:57:06 +0100
commit6b986a63c48267069b982797fad0e4bf3ba12949 (patch)
treef50d1a305e7e554b8c673c24b14a1d2ddb7f38e0 /test
parent23639ce58d487f1783d12b3507ae9369c70e3739 (diff)
downloadlogilab-common-6b986a63c48267069b982797fad0e4bf3ba12949.tar.gz
Fix bug in textutils.apply_units, raise an Exception if string does not match (closes #88808).
Update the dedicated unit test.
Diffstat (limited to 'test')
-rw-r--r--test/unittest_textutils.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/unittest_textutils.py b/test/unittest_textutils.py
index e8b46b1..db18d0d 100644
--- a/test/unittest_textutils.py
+++ b/test/unittest_textutils.py
@@ -184,6 +184,12 @@ class UnitsTC(TestCase):
result = tu.apply_units('1 000 KB', self.units)
self.assertEqual(result, 1000 * self.units['kb'])
+ def test_unit_wrong_input(self):
+ self.assertRaises(ValueError, tu.apply_units, '', self.units)
+ self.assertRaises(ValueError, tu.apply_units, 'wrong input', self.units)
+ self.assertRaises(ValueError, tu.apply_units, 'wrong13 input', self.units)
+ self.assertRaises(ValueError, tu.apply_units, 'wrong input42', self.units)
+
RGX = re.compile('abcd')
class PrettyMatchTC(TestCase):
@@ -246,9 +252,8 @@ class UnormalizeTC(TestCase):
'ab _ cd')
def test_unormalize_backward_compat(self):
- self.assertRaises(ValueError, tu.unormalize, u"\u8000",
- ignorenonascii=False)
- self.assertEqual(tu.unormalize(u"\u8000", ignorenonascii=True), u'')
+ self.assertRaises(ValueError, tu.unormalize, u"\u8000")
+ self.assertEqual(tu.unormalize(u"\u8000", substitute=''), u'')
class ModuleDocTest(DocTest):