#!/usr/bin/env python # coding: utf-8 """ cross compare unittest ~~~~~~~~~~~~~~~~~~~~~~ Compare all similarities between: * creole2html * html2creole * textile2html (used the python textile module) * html2textile Note: This only works fine if there is no problematic whitespace handling. In this case, we must test in test_creole2html.py or test_html2creole.py :copyleft: 2008-2014 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ import unittest from creole.tests.utils.base_unittest import BaseCreoleTest class CrossCompareTests(BaseCreoleTest): """ Cross compare tests for creol2html _and_ html2creole with the same test strings. Used BaseCreoleTest.assertCreole() """ def test_bold_italics(self): self.cross_compare( creole_string=r""" **bold** //italics// //italics and **bold**.// **bold and //italics//.** """, html_string="""
bold italics
italics and bold.
bold and italics.
bold italics
italics and bold.
bold and italics.
bold italics
""", rest_string=""" **bold** *italics* """, ) def test_bold_italics2(self): self.cross_compare( creole_string=r""" **//bold italics//** //**bold italics**// //This is **also** good.// """, html_string="""bold italics
bold italics
This is also good.
bold italics
bold italics
This is also good.
Text before horizontal rule.
Text after the line.
""" ) self.cross_compare( rest_string=all_markups, html_string="""Text before horizontal rule.
Text after the line.
""" ) def test_link(self): self.cross_compare( creole_string=r""" X [[http://domain.tld|link B]] test. """, textile_string=""" X "link B":http://domain.tld test. """, rest_string=""" X `link BX link B test.
""" ) def test_link_without_title(self): self.cross_compare( creole_string=r""" [[http://www.pylucid.org]] """, textile_string=""" "http://www.pylucid.org":http://www.pylucid.org """, rest_string=""" `http://www.pylucid.orgX unknown protocol Y
""" ) def test_link_with_at_sign(self): self.cross_compare( creole_string=r""" X [[http://de.wikipedia.org/wiki/Creole_(Markup)|Creole@wikipedia]] """, html_string=""" """ ) self.cross_compare( rest_string=""" X `Creole@wikipediaa and
a and
a and
a !
a and
a and
a and
a !
1 one
2 two
3 tree
4 four
5 five
""" ) def test_link_image(self): """ FIXME: ReSt. and linked images """ self.cross_compare( creole_string=r""" Linked [[http://example.com/|{{myimage.jpg|example site}} image]] """, html_string="""Linked image
""" ) self.cross_compare( textile_string=""" Linked "!myimage.jpg(example site)! image":http://example.com/ """, html_string="""Linked image
""" ) # self.cross_compare(# FIXME: ReSt # rest_string=""" # I recommend you try |PyLucid CMS|_. # # .. |PyLucid CMS| image:: /images/pylucid.png # .. _PyLucid CMS: http://www.pylucid.org/ # """, # html_string=""" # # """ # ) def test_pre1(self): self.cross_compare( creole_string=r""" {{{ * no list }}} """, textile_string="""* no list""", html_string="""
* no list""") self.cross_compare( # FIXME: Not the best html2rest output rest_string=""" Preformatting text: :: Here some performatting with no `link
Preformatting text:
Here some performatting with no `link <http://domain.tld>`_ here. text... end.
Under pre block
""" ) # def test_pre2(self): # """ TODO: html2creole: wrong lineendings """ # self.cross_compare( # creole_string=r""" # start # # {{{ # * no list # }}} # # end # """, # textile_string=""" # start # ## * no list ## # end # """, # html_string=""" #
start
# ## * no list ## #
end
# """) def test_pre_contains_braces(self): self.cross_compare( creole_string=""" {{{ # Closing braces in nowiki: if (x != NULL) { for (i = 0) { if (x = 1) { x[i]--; }}} }}} """, textile_string="""# Closing braces in nowiki: if (x != NULL) { for (i = 0) { if (x = 1) { x[i]--; }}}""", rest_string=""" :: # Closing braces in nowiki: if (x != NULL) { for (i = 0) { if (x = 1) { x[i]--; }}} """, html_string="""
# Closing braces in nowiki: if (x != NULL) { for (i = 0) { if (x = 1) { x[i]--; }}}""") def test_list(self): """ Bold, Italics, Links, Pre in Lists """ self.cross_compare( creole_string=r""" * **bold** item * //italic// item # item about a [[/foo/bar|certain_page]] """, textile_string=""" * *bold* item * __italic__ item # item about a "certain_page":/foo/bar """, html_string="""
Headline 1 | Headline 2 |
---|---|
cell one | cell two |
Headline 1 | Headline 2 |
---|---|
cell one | cell two |