OILS / doctools / html_lib_test.py View on Github | oilshell.org

49 lines, 35 significant
1#!/usr/bin/env python2
2from __future__ import print_function
3
4import unittest
5
6from doctools import html_lib
7
8
9class FunctionsTest(unittest.TestCase):
10
11 def testPrettyHref(self):
12 self.assertEqual('foo-bar', html_lib.PrettyHref('foo bar', False))
13 self.assertEqual('why-not', html_lib.PrettyHref('Why Not??', False))
14 self.assertEqual('backslash-foo',
15 html_lib.PrettyHref(r'backslash \ foo', False))
16
17 self.assertEqual('cant-touch-this',
18 html_lib.PrettyHref("Can't Touch This!", False))
19
20 self.assertEqual('List/append',
21 html_lib.PrettyHref('List/append', True))
22
23 self.assertEqual('foo-bar', html_lib.PrettyHref('foo bar', True))
24 self.assertEqual('Why-Not', html_lib.PrettyHref('Why Not??', True))
25 self.assertEqual('Cant-Touch-This',
26 html_lib.PrettyHref("Can't Touch This!", True))
27
28 # This is what github does:
29 if 0:
30 self.assertEqual('section-2--3',
31 html_lib.PrettyHref("Section 2 + 3"))
32 self.assertEqual('break--return--continue',
33 html_lib.PrettyHref("break / return / continue"))
34 self.assertEqual('inside-', html_lib.PrettyHref('Inside ${}'))
35 # Ours is cleaner
36 else:
37 self.assertEqual('section-2-3',
38 html_lib.PrettyHref("Section 2 + 3", False))
39 self.assertEqual(
40 'break-return-continue',
41 html_lib.PrettyHref("break / return / continue", False))
42 self.assertEqual('inside',
43 html_lib.PrettyHref('Inside ${}', False))
44 self.assertEqual('bash-compatible',
45 html_lib.PrettyHref('Bash-Compatible', False))
46
47
48if __name__ == '__main__':
49 unittest.main()