#!/usr/bin/env python # coding: utf-8 """ cross compare creole unittest ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Compare all similarities between: * creole2html * html2creole 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-2011 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ import unittest from creole.shared import example_macros from creole.shared.unknown_tags import use_html_macro from creole.tests.utils.base_unittest import BaseCreoleTest class CrossCompareCreoleTests(BaseCreoleTest): def test_typeface(self): self.cross_compare_creole( creole_string=r""" basics: **//bold italics//** //**bold italics**// //This is **also** good.// Creole 1.0 optional: This is ##monospace## text. This is ^^superscripted^^ text. This is ,,subscripted,, text. This is __underlined__ text. own additions: This is --small-- and this ~~strikeout~~ ;) """, html_string="""
basics:
bold italics
bold italics
This is also good.
Creole 1.0 optional:
This is monospace text.
This is superscripted text.
This is subscripted text.
This is underlined text.
own additions:
This is small and this strikeout ;)
Bold and italics should be
able to cross
lines.
no -- small
no // italics
no ** bold
no ## monospace
no ^^ superscripted
no ,, subscripted
no __ underline
this is /a internal link.
1 link A test.
if (x != NULL) { for (i = 0; i < size; i++) { if (x[i] > 0) { x[i]--; }}}""") def test_pre2(self): self.cross_compare_creole(r""" 111 {{{ //This// does **not** get [[formatted]] }}} 222 one {{{ foo bar }}} two """, """
111
//This// does **not** get [[formatted]]
222
one
foo bar
two
""") def test_pre(self): self.cross_compare_creole(r""" start {{{ * no list }}} end """, """start
* no list <html escaped>
end
""") def test_tt(self): self.cross_compare_creole(r""" this is ##**strong** Teletyper## ;) """, """this is strong Teletyper ;)
""") def test_no_inline_headline(self): self.cross_compare_creole( creole_string=r""" = Headline === **not** //parsed// No == headline == or? """, html_string="""No == headline == or?
""" ) def test_horizontal_rule(self): self.cross_compare_creole(r""" one ---- two """, """one
two
""") def test_bullet_list(self): self.cross_compare_creole(r""" * Item 1 ** Item 1.1 ** a **bold** Item 1.2 * Item 2 ** Item 2.1 *** [[a link Item 3.1]] *** Force\\linebreak 3.2 *** item 3.3 *** item 3.4 up to five levels * 1 ** 2 *** 3 **** 4 ***** 5 """, """up to five levels
up to five levels
A Table...
Headline | a other headline |
the big end |
---|---|---|
a cell | a big cell | bold italics |
next line |
No == headline == or? | |
link test: | a link in | a cell. |
empty cells |
...end
""", # debug = True ) def test_html_macro_unknown_nodes(self): """ use the <> macro to mask unknown tags. Note: All cross compare tests use html2creole.HTML_MACRO_UNKNOWN_NODES """ self.cross_compare_creole(""" 111 <>111
333
555
less-than sign: <
greater-than sign: >
>
# some code
# <
>
#
# a macro:
# <>
# <>
# the sourcecode
# <
>
# """, r"""
# [Error: Macro 'a_not_existing_macro' doesn't exist]
#
# a macro:
#
# """)
# def test_macro_pygments_code(self):
# self.cross_compare_creole(r"""
# a macro:
# <>
# /* Stylesheet */
# form * {
# vertical-align:middle;
# }
# <
>
# the end
# """, """
# a macro:
#
# the end
# """)
if __name__ == '__main__':
unittest.main()