diff options
author | JensDiemer <git@jensdiemer.de> | 2012-06-11 17:39:48 +0200 |
---|---|---|
committer | JensDiemer <git@jensdiemer.de> | 2012-06-11 17:39:48 +0200 |
commit | ef52ed0f043a64d089c7d4e976ed50aefe277a6d (patch) | |
tree | ec737a797f5845daf1f0f4dc64d77c04c6f29554 /creole/tests/test_cross_compare_rest.py | |
parent | 52f434c86ad15b411415dec0ee4b8f669d2e1c77 (diff) | |
download | creole-ef52ed0f043a64d089c7d4e976ed50aefe277a6d.tar.gz |
html2rest: Handle double link/image substitution and raise better error messages
Diffstat (limited to 'creole/tests/test_cross_compare_rest.py')
-rw-r--r-- | creole/tests/test_cross_compare_rest.py | 149 |
1 files changed, 123 insertions, 26 deletions
diff --git a/creole/tests/test_cross_compare_rest.py b/creole/tests/test_cross_compare_rest.py index 3af1bef..a63f819 100644 --- a/creole/tests/test_cross_compare_rest.py +++ b/creole/tests/test_cross_compare_rest.py @@ -4,12 +4,12 @@ """ cross compare reStructuredText unittest ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + Compare all similarities between: * rest2html (used docutils) * html2rest - :copyleft: 2011 by python-creole team, see AUTHORS for more details. + :copyleft: 2011-2012 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ @@ -25,7 +25,7 @@ class CrossCompareReStTests(BaseCreoleTest): self.cross_compare_rest( rest_string=""" less-than sign: < - + greater-than sign: > """, html_string=""" @@ -39,9 +39,9 @@ class CrossCompareReStTests(BaseCreoleTest): self.cross_compare_rest( rest_string=""" * item 1 - + * item 2 - + * item 3 """, html_string=""" @@ -58,13 +58,13 @@ class CrossCompareReStTests(BaseCreoleTest): self.cross_compare_rest( rest_string=""" #. item 1 - + #. item 2 - + #. item 2.1 - + #. a `link in </url/>`_ list item 2.2 - + #. item 3 """, html_string=""" @@ -88,25 +88,25 @@ class CrossCompareReStTests(BaseCreoleTest): self.cross_compare_rest( rest_string=""" A nested bullet lists: - + * item 1 - + * A **bold subitem 1.1** here. - + * subsubitem 1.1.1 - + * subsubitem 1.1.2 with inline |substitution text| image. - + * subitem 1.2 - + * item 2 - + * subitem 2.1 - + * *bold 2.2* - + .. |substitution text| image:: /url/to/image.png - + Text under list. """, html_string=""" @@ -168,11 +168,11 @@ class CrossCompareReStTests(BaseCreoleTest): self.cross_compare( rest_string=""" before table. - + +------------+ | table item | +------------+ - + After table. """, html_string=""" @@ -191,7 +191,7 @@ class CrossCompareReStTests(BaseCreoleTest): +---------------+ | `table item`_ | +---------------+ - + .. _table item: foo/bar """, html_string=""" @@ -227,7 +227,7 @@ class CrossCompareReStTests(BaseCreoleTest): +-----------------------------+ | * foo `table item 2`_ bar 2 | +-----------------------------+ - + .. _table item 1: foo/bar/1/ .. _table item 2: foo/bar/2/ """, @@ -238,7 +238,7 @@ class CrossCompareReStTests(BaseCreoleTest): </ul> </td> </tr> - <tr><td><ul> + <tr><td><ul> <li>foo <a href="foo/bar/2/">table item 2</a> bar 2</li> </ul> </td> @@ -255,10 +255,10 @@ class CrossCompareReStTests(BaseCreoleTest): +-----------------+ | `table item 2`_ | +-----------------+ - + .. _table item 1: foo/bar/1/ .. _table item 2: foo/bar/2/ - + Text after table. """, html_string=""" @@ -273,6 +273,103 @@ class CrossCompareReStTests(BaseCreoleTest): # debug=True ) + def test_reuse_link_substitution1(self): + self.cross_compare( + rest_string=""" + +--------------------------------+ + | this is `foo bar`_ first time. | + +--------------------------------+ + | and here `foo bar`_ again. | + +--------------------------------+ + + .. _foo bar: foo/bar/ + + Text after table. + """, + html_string=""" + <table> + <tr><td>this is <a href="foo/bar/">foo bar</a> first time.</td> + </tr> + <tr><td>and here <a href="foo/bar/">foo bar</a> again.</td> + </tr> + </table> + <p>Text after table.</p> + """, +# debug=True + ) + + def test_reuse_link_substitution2(self): + self.cross_compare( + rest_string=""" + +--------------------------------+ + | this is `foo bar`_ first time. | + +--------------------------------+ + + .. _foo bar: foo/bar/ + + and here `foo bar`_ again, after table. + """, + html_string=""" + <table> + <tr><td>this is <a href="foo/bar/">foo bar</a> first time.</td> + </tr> + </table> + <p>and here <a href="foo/bar/">foo bar</a> again, after table.</p> + """, +# debug=True + ) + + def test_reuse_image_substitution(self): + self.cross_compare( + rest_string=""" + +----------------------+ + | first |image| here | + +----------------------+ + | second |image| there | + +----------------------+ + + .. |image| image:: /picture.png + """, + html_string=""" + <table> + <tr><td>first <img alt="image" src="/picture.png" /> here</td> + </tr> + <tr><td>second <img alt="image" src="/picture.png" /> there</td> + </tr> + </table> + """, +# debug=True + ) + + def test_duplicate_image_substitution(self): + self.cross_compare( + rest_string=""" + +----------------------+ + | a |same| image here | + +----------------------+ + | a `same`_ link there | + +----------------------+ + + .. |same| image:: /image.png + .. _same: /url/foo/ + + again: the |same| image and `same`_ link! + """, + html_string=""" + <table> + <tr><td>a <img alt="same" src="/image.png" /> image here</td> + </tr> + <tr><td>a <a href="/url/foo/">same</a> link there</td> + </tr> + </table> + <p>again: the <img alt="same" src="/image.png" /> image and <a href="/url/foo/">same</a> link!</p> + """, +# debug=True + ) + + + + # def test_inline_literal(self): # """ TODO # http://docutils.sourceforge.net/docs/user/rst/quickref.html#inline-markup |