All Downloads are FREE. Search and download functionalities are using the official Maven repository.

build.test.test_parsers.test_rst.test_targets.py Maven / Gradle / Ivy

There is a newer version: 2.4
Show newest version
#! /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> Paragraph. <section dupnames="title" ids="id1"> <title> Title <system_message backrefs="id1" level="1" line="9" source="test data" type="INFO"> <paragraph> Duplicate implicit target name: "title". <paragraph> Paragraph. """], ["""\ Duplicate implicit/explicit targets. Title ===== .. _title: Paragraph. """, """\ <document source="test data"> <paragraph> Duplicate implicit/explicit targets. <section dupnames="title" ids="title"> <title> Title <system_message backrefs="id1" level="1" line="6" source="test data" type="INFO"> <paragraph> Duplicate implicit target name: "title". <target ids="id1" names="title"> <paragraph> Paragraph. """], ["""\ Duplicate implicit/directive targets. Title ===== .. target-notes:: :name: title """, """\ <document source="test data"> <paragraph> Duplicate implicit/directive targets. <section dupnames="title" ids="title"> <title> Title <pending ids="id1" names="title"> <system_message backrefs="id1" level="1" line="4" source="test data" type="INFO"> <paragraph> Duplicate implicit target name: "title". .. internal attributes: .transform: docutils.transforms.references.TargetNotes .details: """], ["""\ Duplicate explicit targets. .. _title: First. .. _title: Second. .. _title: Third. """, """\ <document source="test data"> <paragraph> Duplicate explicit targets. <target dupnames="title" ids="title"> <paragraph> First. <system_message backrefs="id1" level="2" line="7" source="test data" type="WARNING"> <paragraph> Duplicate explicit target name: "title". <target dupnames="title" ids="id1"> <paragraph> Second. <system_message backrefs="id2" level="2" line="11" source="test data" type="WARNING"> <paragraph> Duplicate explicit target name: "title". <target dupnames="title" ids="id2"> <paragraph> Third. """], ["""\ Duplicate explicit/directive targets. .. _title: First. .. rubric:: this is a title too :name: title """, """\ <document source="test data"> <paragraph> Duplicate explicit/directive targets. <target dupnames="title" ids="title"> <paragraph> First. <rubric dupnames="title" ids="id1"> this is a title too <system_message backrefs="id1" level="2" line="9" source="test data" type="WARNING"> <paragraph> 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 """, """\ <document source="test data"> <paragraph> Duplicate targets: <section dupnames="target" ids="target"> <title> Target <paragraph> Implicit section header target. <citation dupnames="target" ids="id1"> <label> TARGET <system_message backrefs="id1" level="1" line="8" source="test data" type="INFO"> <paragraph> Duplicate implicit target name: "target". <paragraph> Citation target. <footnote auto="1" dupnames="target" ids="id2"> <system_message backrefs="id2" level="2" line="10" source="test data" type="WARNING"> <paragraph> Duplicate explicit target name: "target". <paragraph> Autonumber-labeled footnote target. <system_message backrefs="id3" level="2" line="12" source="test data" type="WARNING"> <paragraph> Duplicate explicit target name: "target". <target dupnames="target" ids="id3"> <paragraph> Explicit internal target. <system_message backrefs="id4" level="2" line="16" source="test data" type="WARNING"> <paragraph> Duplicate explicit target name: "target". <target dupnames="target" ids="id4" refuri="Explicit_external_target"> <rubric dupnames="target" ids="id5"> directive with target <system_message backrefs="id5" level="2" line="4" source="test data" type="WARNING"> <paragraph> Duplicate explicit target name: "target". """], ["""\ .. _unescaped colon at end:: no good .. _:: no good either .. _escaped colon\:: OK .. _`unescaped colon, quoted:`: OK """, """\ <document source="test data"> <comment xml:space="preserve"> _unescaped colon at end:: no good <system_message level="2" line="1" source="test data" type="WARNING"> <paragraph> malformed hyperlink target. <comment xml:space="preserve"> _:: no good either <system_message level="2" line="3" source="test data" type="WARNING"> <paragraph> malformed hyperlink target. <target ids="escaped-colon" names="escaped\ colon:" refuri="OK"> <target ids="unescaped-colon-quoted" names="unescaped\ colon,\ quoted:" refuri="OK"> """], ] totest['anonymous_targets'] = [ ["""\ Anonymous external hyperlink target: .. __: http://w3c.org/ """, """\ <document source="test data"> <paragraph> Anonymous external hyperlink target: <target anonymous="1" ids="id1" refuri="http://w3c.org/"> """], ["""\ Anonymous external hyperlink target: __ http://w3c.org/ """, """\ <document source="test data"> <paragraph> Anonymous external hyperlink target: <target anonymous="1" ids="id1" refuri="http://w3c.org/"> """], ["""\ Anonymous indirect hyperlink target: .. __: reference_ """, """\ <document source="test data"> <paragraph> Anonymous indirect hyperlink target: <target anonymous="1" ids="id1" refname="reference"> """], ["""\ Anonymous external hyperlink target, not indirect: __ uri\\_ __ this URI ends with an underscore_ """, """\ <document source="test data"> <paragraph> Anonymous external hyperlink target, not indirect: <target anonymous="1" ids="id1" refuri="uri_"> <target anonymous="1" ids="id2" refuri="thisURIendswithanunderscore_"> """], ["""\ Anonymous indirect hyperlink targets: __ reference_ __ `a very long reference`_ """, """\ <document source="test data"> <paragraph> Anonymous indirect hyperlink targets: <target anonymous="1" ids="id1" refname="reference"> <target anonymous="1" ids="id2" refname="a very long reference"> """], ["""\ Mixed anonymous & named indirect hyperlink targets: __ reference_ .. __: reference_ __ reference_ .. _target1: reference_ no blank line .. _target2: reference_ __ reference_ .. __: reference_ __ reference_ no blank line """, """\ <document source="test data"> <paragraph> Mixed anonymous & named indirect hyperlink targets: <target anonymous="1" ids="id1" refname="reference"> <target anonymous="1" ids="id2" refname="reference"> <target anonymous="1" ids="id3" refname="reference"> <target ids="target1" names="target1" refname="reference"> <system_message level="2" line="7" source="test data" type="WARNING"> <paragraph> Explicit markup ends without a blank line; unexpected unindent. <paragraph> no blank line <target ids="target2" names="target2" refname="reference"> <target anonymous="1" ids="id4" refname="reference"> <target anonymous="1" ids="id5" refname="reference"> <target anonymous="1" ids="id6" refname="reference"> <system_message level="2" line="13" source="test data" type="WARNING"> <paragraph> Explicit markup ends without a blank line; unexpected unindent. <paragraph> no blank line """], ["""\ .. _ """, """\ <document source="test data"> <comment xml:space="preserve"> _ """], ] if __name__ == '__main__': import unittest unittest.main(defaultTest='suite') </code></pre> <br/> <br/> <div id="right-banner"> </div> <div id="left-banner"> </div> <div class='clear'></div> <aside class="related-items"> <section> <div class="panel panel-primary"> <div class="panel-heading margin-bottom">Related Artifacts</div> <div class=""> <a title='This artifact is from the group mysql' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/mysql/mysql-connector-java' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> mysql-connector-java <small class='group-info' >mysql</small></a><br/><a title='This artifact is from the group com.github.codedrinker' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.github.codedrinker/facebook-messenger' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> facebook-messenger <small class='group-info' >com.github.codedrinker</small></a><br/><a title='This artifact is from the group org.seleniumhq.selenium' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.seleniumhq.selenium/selenium-java' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> selenium-java <small class='group-info' >org.seleniumhq.selenium</small></a><br/><a title='This artifact is from the group com.github.sola92' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.github.sola92/instagram-java' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> instagram-java <small class='group-info' >com.github.sola92</small></a><br/><a title='This artifact is from the group com.google.code.gson' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.google.code.gson/gson' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> gson <small class='group-info' >com.google.code.gson</small></a><br/><a title='This artifact is from the group org.apache.poi' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.apache.poi/poi' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> poi <small class='group-info' >org.apache.poi</small></a><br/><a title='This artifact is from the group org.apache.httpcomponents' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.apache.httpcomponents/httpclient' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> httpclient <small class='group-info' >org.apache.httpcomponents</small></a><br/><a title='This artifact is from the group org.json' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.json/json' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> json <small class='group-info' >org.json</small></a><br/><a title='This artifact is from the group com.google.code.facebook-java-api' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.google.code.facebook-java-api/facebook-java-api' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> facebook-java-api <small class='group-info' >com.google.code.facebook-java-api</small></a><br/><a title='This artifact is from the group org.apache.poi' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.apache.poi/poi-ooxml' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> poi-ooxml <small class='group-info' >org.apache.poi</small></a><br/><a title='This artifact is from the group com.fasterxml.jackson.core' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.fasterxml.jackson.core/jackson-databind' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> jackson-databind <small class='group-info' >com.fasterxml.jackson.core</small></a><br/><a title='This artifact is from the group junit' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/junit/junit' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> junit <small class='group-info' >junit</small></a><br/><a title='This artifact is from the group org.primefaces' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.primefaces/primefaces' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> primefaces <small class='group-info' >org.primefaces</small></a><br/><a title='This artifact is from the group com.github.noraui' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.github.noraui/ojdbc7' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> ojdbc7 <small class='group-info' >com.github.noraui</small></a><br/><a title='This artifact is from the group com.jfoenix' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.jfoenix/jfoenix' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> jfoenix <small class='group-info' >com.jfoenix</small></a><br/><a title='This artifact is from the group org.testng' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.testng/testng' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> testng <small class='group-info' >org.testng</small></a><br/><a title='This artifact is from the group com.googlecode.json-simple' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.googlecode.json-simple/json-simple' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> json-simple <small class='group-info' >com.googlecode.json-simple</small></a><br/><a title='This artifact is from the group org.seleniumhq.selenium' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.seleniumhq.selenium/selenium-server' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> selenium-server <small class='group-info' >org.seleniumhq.selenium</small></a><br/><a title='This artifact is from the group com.itextpdf' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.itextpdf/itextpdf' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> itextpdf <small class='group-info' >com.itextpdf</small></a><br/><a title='This artifact is from the group org.springframework' class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.springframework/spring-core' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> spring-core <small class='group-info' >org.springframework</small></a><br/> </div> </div> </section> <section> <div class="panel panel-primary"> <div class="panel-heading margin-bottom">Related Groups</div> <div class=""> <a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.springframework' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.springframework</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.apache.poi' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.apache.poi</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.hibernate' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.hibernate</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.springframework.boot' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.springframework.boot</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.fasterxml.jackson.core' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> com.fasterxml.jackson.core</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.itextpdf' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> com.itextpdf</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.seleniumhq.selenium' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.seleniumhq.selenium</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/mysql' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> mysql</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.finos.legend.engine' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.finos.legend.engine</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.apache.httpcomponents' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.apache.httpcomponents</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.apache.logging.log4j' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.apache.logging.log4j</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.openjfx' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.openjfx</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.apache.commons' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.apache.commons</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/org.json' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> org.json</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.google.guava' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> com.google.guava</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.google.zxing' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> com.google.zxing</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/net.sf.jasperreports' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> net.sf.jasperreports</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/javax.xml.bind' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> javax.xml.bind</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/ojdbc' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> ojdbc</a><br/><a class='btn btn-default btn-xs small-margin-bottom ellipsis sidebar-btn' href='/artifacts/com.google.code.facebook-java-api' ><i class="fa fa-arrow-circle-right" aria-hidden="true"></i> com.google.code.facebook-java-api</a><br/> </div> </div> </section> </aside> <div class='clear'></div> </main> </div> <br/><br/> <div class="align-center">© 2015 - 2024 <a href="/legal-notice.php">Weber Informatics LLC</a> | <a href="/data-protection.php">Privacy Policy</a></div> <br/><br/><br/><br/><br/><br/> </body> </html> <script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script>