OILS / doctools / html_lib_test.py View on Github | oils.pub

50 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 # type: () -> None
13 self.assertEqual('foo-bar', html_lib.PrettyHref('foo bar', False))
14 self.assertEqual('why-not', html_lib.PrettyHref('Why Not??', False))
15 self.assertEqual('backslash-foo',
16 html_lib.PrettyHref(r'backslash \ foo', False))
17
18 self.assertEqual('cant-touch-this',
19 html_lib.PrettyHref("Can't Touch This!", False))
20
21 self.assertEqual('List/append',
22 html_lib.PrettyHref('List/append', True))
23
24 self.assertEqual('foo-bar', html_lib.PrettyHref('foo bar', True))
25 self.assertEqual('Why-Not', html_lib.PrettyHref('Why Not??', True))
26 self.assertEqual('Cant-Touch-This',
27 html_lib.PrettyHref("Can't Touch This!", True))
28
29 # This is what github does:
30 if 0:
31 self.assertEqual('section-2--3',
32 html_lib.PrettyHref("Section 2 + 3"))
33 self.assertEqual('break--return--continue',
34 html_lib.PrettyHref("break / return / continue"))
35 self.assertEqual('inside-', html_lib.PrettyHref('Inside ${}'))
36 # Ours is cleaner
37 else:
38 self.assertEqual('section-2-3',
39 html_lib.PrettyHref("Section 2 + 3", False))
40 self.assertEqual(
41 'break-return-continue',
42 html_lib.PrettyHref("break / return / continue", False))
43 self.assertEqual('inside',
44 html_lib.PrettyHref('Inside ${}', False))
45 self.assertEqual('bash-compatible',
46 html_lib.PrettyHref('Bash-Compatible', False))
47
48
49if __name__ == '__main__':
50 unittest.main()