summaryrefslogtreecommitdiff
path: root/test/test_parsers/test_rst/test_functions.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_parsers/test_rst/test_functions.py')
-rwxr-xr-xtest/test_parsers/test_rst/test_functions.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test_parsers/test_rst/test_functions.py b/test/test_parsers/test_rst/test_functions.py
new file mode 100755
index 000000000..e6694b2c5
--- /dev/null
+++ b/test/test_parsers/test_rst/test_functions.py
@@ -0,0 +1,38 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for states.py.
+"""
+
+import unittest
+from __init__ import DocutilsTestSupport
+states = DocutilsTestSupport.states
+
+
+class FuctionTests(unittest.TestCase):
+
+ escaped = r'escapes: \*one, \\*two, \\\*three'
+ nulled = 'escapes: \x00*one, \x00\\*two, \x00\\\x00*three'
+ unescaped = r'escapes: *one, \*two, \*three'
+
+ def test_escape2null(self):
+ nulled = states.escape2null(self.escaped)
+ self.assertEquals(nulled, self.nulled)
+ nulled = states.escape2null(self.escaped + '\\')
+ self.assertEquals(nulled, self.nulled + '\x00')
+
+ def test_unescape(self):
+ unescaped = states.unescape(self.nulled)
+ self.assertEquals(unescaped, self.unescaped)
+ restored = states.unescape(self.nulled, 1)
+ self.assertEquals(restored, self.escaped)
+
+
+if __name__ == '__main__':
+ unittest.main()