File: test_functions.py

package info (click to toggle)
python-docutils 0.14%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,976 kB
  • sloc: python: 44,718; lisp: 14,476; xml: 1,782; sh: 167; makefile: 150
file content (36 lines) | stat: -rwxr-xr-x 1,041 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/env python

# $Id: test_functions.py 7337 2012-02-03 08:16:53Z milde $
# Author: David Goodger <goodger@python.org>
# 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.assertEqual(nulled, self.nulled)
        nulled = states.escape2null(self.escaped + '\\')
        self.assertEqual(nulled, self.nulled + '\x00')

    def test_unescape(self):
        unescaped = states.unescape(self.nulled)
        self.assertEqual(unescaped, self.unescaped)
        restored = states.unescape(self.nulled, 1)
        self.assertEqual(restored, self.escaped)


if __name__ == '__main__':
    unittest.main()