test.test_transforms.test_sectnum.py Maven / Gradle / Ivy
#! /usr/bin/env python
# $Id: test_sectnum.py 4564 2006-05-21 20:44:42Z wiemann $
# Authors: David Goodger ; Dmitry Jemerov
# Copyright: This module has been placed in the public domain.
"""
Tests for `docutils.transforms.parts.SectNum` (via
`docutils.transforms.universal.LastReaderPending`).
"""
from __init__ import DocutilsTestSupport
from docutils.transforms.references import Substitutions
from docutils.parsers.rst import Parser
def suite():
parser = Parser()
s = DocutilsTestSupport.TransformTestSuite(parser)
s.generateTests(totest)
return s
totest = {}
totest['section_numbers'] = ((Substitutions,), [
["""\
.. sectnum::
Title 1
=======
Paragraph 1.
Title 2
-------
Paragraph 2.
Title 3
```````
Paragraph 3.
Title 4
-------
Paragraph 4.
""",
u"""\
1\u00a0\u00a0\u00a0
Title 1
Paragraph 1.
1.1\u00a0\u00a0\u00a0
Title 2
Paragraph 2.
1.1.1\u00a0\u00a0\u00a0
Title 3
Paragraph 3.
1.2\u00a0\u00a0\u00a0
Title 4
Paragraph 4.
"""],
["""\
.. sectnum::
**Bold Title**
==============
Paragraph 1.
""",
u"""\
1\u00a0\u00a0\u00a0
Bold Title
Paragraph 1.
"""],
["""\
.. sectnum:: :depth: 2
Title 1
=======
Paragraph 1.
Title 2
-------
Paragraph 2.
Title 3
```````
Paragraph 3.
Title 4
-------
Paragraph 4.
""",
u"""\
1\u00a0\u00a0\u00a0
Title 1
Paragraph 1.
1.1\u00a0\u00a0\u00a0
Title 2
Paragraph 2.
Title 3
Paragraph 3.
1.2\u00a0\u00a0\u00a0
Title 4
Paragraph 4.
"""],
["""\
.. contents::
.. sectnum:: :depth: 2
Title 1
=======
Paragraph 1.
Title 2
-------
Paragraph 2.
Title 3
```````
Paragraph 3.
Title 4
-------
Paragraph 4.
""",
u"""\
Contents
1\u00a0\u00a0\u00a0
Title 1
1.1\u00a0\u00a0\u00a0
Title 2
Title 3
1.2\u00a0\u00a0\u00a0
Title 4
1\u00a0\u00a0\u00a0
Title 1
Paragraph 1.
1.1\u00a0\u00a0\u00a0
Title 2
Paragraph 2.
Title 3
Paragraph 3.
1.2\u00a0\u00a0\u00a0
Title 4
Paragraph 4.
"""],
["""\
.. sectnum::
:prefix: Arbitrary-
Title 1
=======
Paragraph 1.
Title 2
-------
Paragraph 2.
Title 3
```````
Paragraph 3.
Title 4
-------
Paragraph 4.
""",
u"""\
Arbitrary-1\u00a0\u00a0\u00a0
Title 1
Paragraph 1.
Arbitrary-1.1\u00a0\u00a0\u00a0
Title 2
Paragraph 2.
Arbitrary-1.1.1\u00a0\u00a0\u00a0
Title 3
Paragraph 3.
Arbitrary-1.2\u00a0\u00a0\u00a0
Title 4
Paragraph 4.
"""],
["""\
.. sectnum::
:start: 3
Title 1
=======
Paragraph 1.
Title 2
-------
Paragraph 2.
Title 3
```````
Paragraph 3.
Title 4
-------
Paragraph 4.
""",
u"""\
3\u00a0\u00a0\u00a0
Title 1
Paragraph 1.
3.1\u00a0\u00a0\u00a0
Title 2
Paragraph 2.
3.1.1\u00a0\u00a0\u00a0
Title 3
Paragraph 3.
3.2\u00a0\u00a0\u00a0
Title 4
Paragraph 4.
"""],
["""\
.. sectnum::
:prefix: (5.9.
:suffix: )
:start: 3
Title 1
=======
Paragraph 1.
Title 2
-------
Paragraph 2.
Title 3
```````
Paragraph 3.
Title 4
-------
Paragraph 4.
""",
u"""\
(5.9.3)\u00a0\u00a0\u00a0
Title 1
Paragraph 1.
(5.9.3.1)\u00a0\u00a0\u00a0
Title 2
Paragraph 2.
(5.9.3.1.1)\u00a0\u00a0\u00a0
Title 3
Paragraph 3.
(5.9.3.2)\u00a0\u00a0\u00a0
Title 4
Paragraph 4.
"""],
])
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')