safe check for startswith "."
[docutils.git] / test / test_parsers / test_rst / test_functions.py
blob66dc2c8cd82678bf127ab949df1608de42c489a1
1 #! /usr/bin/env python
3 # $Id$
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for states.py.
9 """
11 import unittest
12 from __init__ import DocutilsTestSupport
13 states = DocutilsTestSupport.states
16 class FuctionTests(unittest.TestCase):
18 escaped = r'escapes: \*one, \\*two, \\\*three'
19 nulled = 'escapes: \x00*one, \x00\\*two, \x00\\\x00*three'
20 unescaped = r'escapes: *one, \*two, \*three'
22 def test_escape2null(self):
23 nulled = states.escape2null(self.escaped)
24 self.assertEqual(nulled, self.nulled)
25 nulled = states.escape2null(self.escaped + '\\')
26 self.assertEqual(nulled, self.nulled + '\x00')
28 def test_unescape(self):
29 unescaped = states.unescape(self.nulled)
30 self.assertEqual(unescaped, self.unescaped)
31 restored = states.unescape(self.nulled, 1)
32 self.assertEqual(restored, self.escaped)
35 if __name__ == '__main__':
36 unittest.main()