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.
#! /usr/bin/env python
# $Id: test_substitutions.py 4564 2006-05-21 20:44:42Z wiemann $
# 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['substitution_definitions'] = [
["""\
Here's an image substitution definition:
.. |symbol| image:: symbol.png
""",
"""\
Here's an image substitution definition:
"""],
["""\
Embedded directive starts on the next line:
.. |symbol|
image:: symbol.png
""",
"""\
Embedded directive starts on the next line:
"""],
["""\
Trailing spaces should not be significant:
.. |symbol| image:: \n\
symbol.png
""",
"""\
Trailing spaces should not be significant:
"""],
["""\
Here's a series of substitution definitions:
.. |symbol 1| image:: symbol1.png
.. |SYMBOL 2| image:: symbol2.png
:height: 50
:width: 100
.. |symbol 3| image:: symbol3.png
""",
"""\
Here's a series of substitution definitions:
"""],
["""\
.. |very long substitution text,
split across lines| image:: symbol.png
""",
"""\
"""],
["""\
.. |symbol 1| image:: symbol.png
Followed by a block quote.
""",
"""\
Error in "image" directive:
no content permitted.
image:: symbol.png
\n\
Followed by a block quote.
Substitution definition "symbol 1" empty or invalid.
.. |symbol 1| image:: symbol.png
\n\
Followed by a block quote.
"""],
["""\
.. |symbol 1| image:: symbol.png
Followed by a paragraph.
.. |symbol 2| image:: symbol.png
..
Followed by a block quote.
""",
"""\
Followed by a paragraph.
Followed by a block quote.
"""],
[u"""\
Substitutions support case differences:
.. |eacute| replace:: \u00E9
.. |Eacute| replace:: \u00C9
""",
u"""\
Substitutions support case differences:
\u00E9
\u00C9
"""],
["""\
Raw substitution, backslashes should be preserved:
.. |alpha| raw:: latex
$\\\\alpha$
""",
"""\
Raw substitution, backslashes should be preserved:
$\\\\alpha$
"""],
["""\
Here are some duplicate substitution definitions:
.. |symbol| image:: symbol.png
.. |symbol| image:: symbol.png
""",
"""\
Here are some duplicate substitution definitions:
Duplicate substitution definition name: "symbol".
"""],
["""\
Here are some bad cases:
.. |symbol| image:: symbol.png
No blank line after.
.. |empty|
.. |unknown| directive:: symbol.png
.. |invalid 1| there's no directive here
.. |invalid 2| there's no directive here
With some block quote text, line 1.
And some more, line 2.
.. |invalid 3| there's no directive here
.. | bad name | bad data
.. |
""",
"""\
Here are some bad cases:
Explicit markup ends without a blank line; unexpected unindent.
No blank line after.
Substitution definition "empty" missing contents.
.. |empty|
No directive entry for "directive" in module "docutils.parsers.rst.languages.en".
Trying "directive" as canonical directive name.
Unknown directive type "directive".
directive:: symbol.png
Substitution definition "unknown" empty or invalid.
.. |unknown| directive:: symbol.png
Substitution definition "invalid 1" empty or invalid.
.. |invalid 1| there's no directive here
Substitution definition "invalid 2" empty or invalid.
.. |invalid 2| there's no directive here
With some block quote text, line 1.
And some more, line 2.
Substitution definition "invalid 3" empty or invalid.
.. |invalid 3| there's no directive here
| bad name | bad data
|
"""],
["""\
Elements that are prohibited inside of substitution definitions:
.. |target| replace:: _`target`
.. |reference| replace:: anonymous__
.. |auto-numbered footnote| replace:: [#]_
""",
"""\
Elements that are prohibited inside of substitution definitions:
Substitution definition contains illegal element:
target
.. |target| replace:: _`target`
Substitution definition contains illegal element:
anonymous
.. |reference| replace:: anonymous__
Substitution definition contains illegal element:
.. |auto-numbered footnote| replace:: [#]_
"""],
]
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')