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

34 lines, 22 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('cant-touch-this', html_lib.PrettyHref("Can't Touch This!", False))
15
16 self.assertEqual('foo-bar', html_lib.PrettyHref('foo bar', True))
17 self.assertEqual('Why-Not', html_lib.PrettyHref('Why Not??', True))
18 self.assertEqual('Cant-Touch-This', html_lib.PrettyHref("Can't Touch This!", True))
19
20 # This is what github does:
21 if 0:
22 self.assertEqual('section-2--3', html_lib.PrettyHref("Section 2 + 3"))
23 self.assertEqual('break--return--continue', html_lib.PrettyHref("break / return / continue"))
24 self.assertEqual('inside-', html_lib.PrettyHref('Inside ${}'))
25 # Ours is cleaner
26 else:
27 self.assertEqual('section-2-3', html_lib.PrettyHref("Section 2 + 3", False))
28 self.assertEqual('break-return-continue', html_lib.PrettyHref("break / return / continue", False))
29 self.assertEqual('inside', html_lib.PrettyHref('Inside ${}', False))
30 self.assertEqual('bash-compatible', html_lib.PrettyHref('Bash-Compatible', False))
31
32
33if __name__ == '__main__':
34 unittest.main()