Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
build.test.test_parsers.test_rst.test_targets.py Maven / Gradle / Ivy
#! /usr/bin/env python
# $Id: test_targets.py 7062 2011-06-30 22:14:29Z milde $
# Author: David Goodger
# Copyright: This module has been placed in the public domain.
"""
Tests for states.py.
"""
from __init__ import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
return s
totest = {}
totest['targets'] = [
["""\
.. _target:
(Internal hyperlink target.)
""",
"""\
(Internal hyperlink target.)
"""],
["""\
.. _optional space before colon :
""",
"""\
"""],
["""\
External hyperlink targets:
.. _one-liner: http://structuredtext.sourceforge.net
.. _starts-on-this-line: http://
structuredtext.
sourceforge.net
.. _entirely-below:
http://structuredtext.
sourceforge.net
.. _not-indirect: uri\\_
""",
"""\
External hyperlink targets:
"""],
["""\
Indirect hyperlink targets:
.. _target1: reference_
.. _target2: `phrase-link reference`_
""",
"""\
Indirect hyperlink targets:
"""],
["""\
.. _a long target name:
.. _`a target name: including a colon (quoted)`:
.. _a target name\: including a colon (escaped):
""",
"""\
"""],
["""\
.. _`target: No matching backquote.
.. _`: No matching backquote either.
""",
"""\
_`target: No matching backquote.
malformed hyperlink target.
_`: No matching backquote either.
malformed hyperlink target.
"""],
["""\
.. _a very long target name,
split across lines:
.. _`and another,
with backquotes`:
""",
"""\
"""],
["""\
External hyperlink:
.. _target: http://www.python.org/
""",
"""\
External hyperlink:
"""],
["""\
.. _email: [email protected]
.. _multi-line email: jdoe
@example.com
""",
"""\
"""],
["""\
Malformed target:
.. __malformed: no good
Target beginning with an underscore:
.. _`_target`: OK
""",
"""\
Malformed target:
__malformed: no good
malformed hyperlink target.
Target beginning with an underscore:
"""],
["""\
Duplicate external targets (different URIs):
.. _target: first
.. _target: second
""",
"""\
Duplicate external targets (different URIs):
Duplicate explicit target name: "target".
"""],
["""\
Duplicate external targets (same URIs):
.. _target: first
.. _target: first
""",
"""\
Duplicate external targets (same URIs):
Duplicate explicit target name: "target".
"""],
["""\
Duplicate implicit targets.
Title
=====
Paragraph.
Title
=====
Paragraph.
""",
"""\
Duplicate implicit targets.
Title
Paragraph.
Title
Duplicate implicit target name: "title".
Paragraph.
"""],
["""\
Duplicate implicit/explicit targets.
Title
=====
.. _title:
Paragraph.
""",
"""\
Duplicate implicit/explicit targets.
Title
Duplicate implicit target name: "title".
Paragraph.
"""],
["""\
Duplicate implicit/directive targets.
Title
=====
.. target-notes::
:name: title
""",
"""\
Duplicate implicit/directive targets.
Title
Duplicate implicit target name: "title".
.. internal attributes:
.transform: docutils.transforms.references.TargetNotes
.details:
"""],
["""\
Duplicate explicit targets.
.. _title:
First.
.. _title:
Second.
.. _title:
Third.
""",
"""\
Duplicate explicit targets.
First.
Duplicate explicit target name: "title".
Second.
Duplicate explicit target name: "title".
Third.
"""],
["""\
Duplicate explicit/directive targets.
.. _title:
First.
.. rubric:: this is a title too
:name: title
""",
"""\
Duplicate explicit/directive targets.
First.
this is a title too
Duplicate explicit target name: "title".
"""],
["""\
Duplicate targets:
Target
======
Implicit section header target.
.. [TARGET] Citation target.
.. [#target] Autonumber-labeled footnote target.
.. _target:
Explicit internal target.
.. _target: Explicit_external_target
.. rubric:: directive with target
:name: Target
""",
"""\
Duplicate targets:
Target
Implicit section header target.
TARGET
Duplicate implicit target name: "target".
Citation target.
Duplicate explicit target name: "target".
Autonumber-labeled footnote target.
Duplicate explicit target name: "target".
Explicit internal target.
Duplicate explicit target name: "target".
directive with target
Duplicate explicit target name: "target".
"""],
["""\
.. _unescaped colon at end:: no good
.. _:: no good either
.. _escaped colon\:: OK
.. _`unescaped colon, quoted:`: OK
""",
"""\
_unescaped colon at end:: no good
malformed hyperlink target.
_:: no good either
malformed hyperlink target.
"""],
]
totest['anonymous_targets'] = [
["""\
Anonymous external hyperlink target:
.. __: http://w3c.org/
""",
"""\
Anonymous external hyperlink target:
"""],
["""\
Anonymous external hyperlink target:
__ http://w3c.org/
""",
"""\
Anonymous external hyperlink target:
"""],
["""\
Anonymous indirect hyperlink target:
.. __: reference_
""",
"""\
Anonymous indirect hyperlink target:
"""],
["""\
Anonymous external hyperlink target, not indirect:
__ uri\\_
__ this URI ends with an underscore_
""",
"""\
Anonymous external hyperlink target, not indirect:
"""],
["""\
Anonymous indirect hyperlink targets:
__ reference_
__ `a very long
reference`_
""",
"""\
Anonymous indirect hyperlink targets:
"""],
["""\
Mixed anonymous & named indirect hyperlink targets:
__ reference_
.. __: reference_
__ reference_
.. _target1: reference_
no blank line
.. _target2: reference_
__ reference_
.. __: reference_
__ reference_
no blank line
""",
"""\
Mixed anonymous & named indirect hyperlink targets:
Explicit markup ends without a blank line; unexpected unindent.
no blank line
Explicit markup ends without a blank line; unexpected unindent.
no blank line
"""],
["""\
.. _
""",
"""\
_
"""],
]
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')