|
|
@ -71,8 +71,9 @@ class TestText(unittest.TestCase):
|
|
|
|
# standard usage
|
|
|
|
# standard usage
|
|
|
|
self.assertEqual(f(""), empty)
|
|
|
|
self.assertEqual(f(""), empty)
|
|
|
|
self.assertEqual(f("Hello World."), ["Hello World."])
|
|
|
|
self.assertEqual(f("Hello World."), ["Hello World."])
|
|
|
|
self.assertEqual(f(" Hello World. "), [" Hello World. "])
|
|
|
|
self.assertEqual(f(" Hello World. "), ["Hello World."])
|
|
|
|
self.assertEqual(f("Hello<br/>World."), result)
|
|
|
|
self.assertEqual(f("Hello<br/>World."), result)
|
|
|
|
|
|
|
|
self.assertEqual(f(" Hello <br/> World. "), result)
|
|
|
|
self.assertEqual(
|
|
|
|
self.assertEqual(
|
|
|
|
f("<div><b class='a'>Hello</b><i>World.</i></div>"), result)
|
|
|
|
f("<div><b class='a'>Hello</b><i>World.</i></div>"), result)
|
|
|
|
|
|
|
|
|
|
|
@ -260,6 +261,27 @@ class TestText(unittest.TestCase):
|
|
|
|
self.assertEqual(f(value, default), default)
|
|
|
|
self.assertEqual(f(value, default), default)
|
|
|
|
self.assertEqual(f("zzz", default), default)
|
|
|
|
self.assertEqual(f("zzz", default), default)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_parse_float(self, f=text.parse_float):
|
|
|
|
|
|
|
|
self.assertEqual(f(0), 0.0)
|
|
|
|
|
|
|
|
self.assertEqual(f("0"), 0.0)
|
|
|
|
|
|
|
|
self.assertEqual(f(123), 123.0)
|
|
|
|
|
|
|
|
self.assertEqual(f("123"), 123.0)
|
|
|
|
|
|
|
|
self.assertEqual(f(123.456), 123.456)
|
|
|
|
|
|
|
|
self.assertEqual(f("123.456"), 123.456)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# invalid arguments
|
|
|
|
|
|
|
|
for value in INVALID_ALT:
|
|
|
|
|
|
|
|
self.assertEqual(f(value), 0.0)
|
|
|
|
|
|
|
|
self.assertEqual(f("zzz"), 0.0)
|
|
|
|
|
|
|
|
self.assertEqual(f([1, 2, 3]), 0.0)
|
|
|
|
|
|
|
|
self.assertEqual(f({1: 2, 3: 4}), 0.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 'default' argument
|
|
|
|
|
|
|
|
default = "default"
|
|
|
|
|
|
|
|
for value in INVALID_ALT:
|
|
|
|
|
|
|
|
self.assertEqual(f(value, default), default)
|
|
|
|
|
|
|
|
self.assertEqual(f("zzz", default), default)
|
|
|
|
|
|
|
|
|
|
|
|
def test_parse_query(self, f=text.parse_query):
|
|
|
|
def test_parse_query(self, f=text.parse_query):
|
|
|
|
# standard usage
|
|
|
|
# standard usage
|
|
|
|
self.assertEqual(f(""), {})
|
|
|
|
self.assertEqual(f(""), {})
|
|
|
|