-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
34 lines (24 loc) · 1.21 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
# To run:
# python3 tests.py
# This used to have a lot of tests for the Template and ParamFile classes.
# But we've gotten rid of those. So this is pretty vestigial.
import unittest
from ifmap import is_string_nonwhite
from ifmap import escape_html_string
class TestEscapeFunctions(unittest.TestCase):
def test_escape_html_string(self):
self.assertEqual(escape_html_string('foo'), 'foo')
self.assertEqual(escape_html_string('foo<i>&'), 'foo<i>&')
self.assertEqual(escape_html_string('w x\ny\tz'), 'w x\ny\tz')
self.assertEqual(escape_html_string('x\x01y'), 'xy')
self.assertEqual(escape_html_string('© αβγδε “”'), '© αβγδε “”')
def test_is_string_nonwhite(self):
self.assertIs(is_string_nonwhite(''), False)
self.assertIs(is_string_nonwhite(' '), False)
self.assertIs(is_string_nonwhite('\n \t \n'), False)
self.assertIs(is_string_nonwhite('x'), True)
self.assertIs(is_string_nonwhite('x \n'), True)
self.assertIs(is_string_nonwhite('\n x'), True)
if __name__ == '__main__':
unittest.main()