diff options
Diffstat (limited to 'creole/tests/utils/base_unittest.py')
-rw-r--r-- | creole/tests/utils/base_unittest.py | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/creole/tests/utils/base_unittest.py b/creole/tests/utils/base_unittest.py index 5f6bba4..3d28c94 100644 --- a/creole/tests/utils/base_unittest.py +++ b/creole/tests/utils/base_unittest.py @@ -10,7 +10,6 @@ """ - import re import warnings @@ -30,7 +29,6 @@ else: test_textile = True - try: from creole.rest_tools.clean_writer import rest2html except DocutilsImportError as err: @@ -42,7 +40,6 @@ else: tabs2spaces_re = re.compile(r"^(\t*)(.*?)$", re.M) - def tabs2spaces(html): """ form reformating textile html code >>> tabs2spaces("\\t<p>one<br />\\n\\t\\ttwo<br />\\n\\t\\t\\ttree</p>") @@ -72,11 +69,11 @@ def strip_html_lines(html, strip_lines=False): return html - class BaseCreoleTest(MarkupTest): """ Basic unittest class for all python-creole unittest classes. """ + def _debug_text(self, msg, raw_text): text = raw_text.replace(" ", ".") text = text.replace("\n", "\\n\n") @@ -89,12 +86,12 @@ class BaseCreoleTest(MarkupTest): print("-" * 79) def assert_creole2html( - self, raw_creole, raw_html, - strip_lines=False, debug=True, - parser_kwargs={}, emitter_kwargs={}, - block_rules=None, blog_line_breaks=True, macros=None, verbose=True, stderr=None, - strict=False, - ): + self, raw_creole, raw_html, + strip_lines=False, debug=True, + parser_kwargs={}, emitter_kwargs={}, + block_rules=None, blog_line_breaks=True, macros=None, verbose=True, stderr=None, + strict=False, + ): """ compare the generated html code from the markup string >creole_string< with the >html_string< reference. @@ -131,10 +128,10 @@ class BaseCreoleTest(MarkupTest): self.assertEqual(out_string, html_string, msg="creole2html") def assert_html2creole2(self, creole, html, - debug=True, - unknown_emit=None, - strict=False, - ): + debug=True, + unknown_emit=None, + strict=False, + ): # convert html code into creole markup out_string = html2creole( html, debug, unknown_emit=unknown_emit, strict=strict @@ -144,14 +141,14 @@ class BaseCreoleTest(MarkupTest): # compare self.assertEqual(out_string, creole, msg="html2creole") - def assert_html2creole(self, raw_creole, raw_html, \ - strip_lines=False, debug=True, - # OLD API: - parser_kwargs={}, emitter_kwargs={}, - # html2creole: - unknown_emit=None, - strict=False, - ): + def assert_html2creole(self, raw_creole, raw_html, + strip_lines=False, debug=True, + # OLD API: + parser_kwargs={}, emitter_kwargs={}, + # html2creole: + unknown_emit=None, + strict=False, + ): """ Compare the genereted markup from the given >raw_html< html code, with the given >creole_string< reference string. @@ -176,17 +173,17 @@ class BaseCreoleTest(MarkupTest): self.assert_html2creole2(creole, html, debug, unknown_emit, strict) def cross_compare_creole(self, creole_string, html_string, - strip_lines=False, debug=True, - # creole2html old API: - creole_parser_kwargs={}, html_emitter_kwargs={}, - # html2creole old API: - html_parser_kwargs={}, creole_emitter_kwargs={}, - - # creole2html new API: - block_rules=None, blog_line_breaks=True, macros=None, stderr=None, - # html2creole: - unknown_emit=None - ): + strip_lines=False, debug=True, + # creole2html old API: + creole_parser_kwargs={}, html_emitter_kwargs={}, + # html2creole old API: + html_parser_kwargs={}, creole_emitter_kwargs={}, + + # creole2html new API: + block_rules=None, blog_line_breaks=True, macros=None, stderr=None, + # html2creole: + unknown_emit=None + ): """ Cross compare with: * creole2html @@ -213,8 +210,8 @@ class BaseCreoleTest(MarkupTest): unknown_emit=unknown_emit, ) - def assert_html2textile(self, textile_string, html_string, \ - strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): + def assert_html2textile(self, textile_string, html_string, + strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): """ Check html2textile """ @@ -237,8 +234,8 @@ class BaseCreoleTest(MarkupTest): return textile_string, html_string - def cross_compare_textile(self, textile_string, html_string, \ - strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): + def cross_compare_textile(self, textile_string, html_string, + strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): """ Checks: * html2textile @@ -268,8 +265,8 @@ class BaseCreoleTest(MarkupTest): self.assertEqual(html_string, html, msg="textile2html") - def assert_html2rest(self, rest_string, html_string, \ - strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): + def assert_html2rest(self, rest_string, html_string, + strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): """ Check html to reStructuredText converter """ @@ -294,8 +291,8 @@ class BaseCreoleTest(MarkupTest): return rest_string, html_string - def assert_rest2html(self, rest_string, html_string, \ - strip_lines=False, debug=False, prepare_strings=True, **kwargs): + def assert_rest2html(self, rest_string, html_string, + strip_lines=False, debug=False, prepare_strings=True, **kwargs): # compare rest -> html if not REST_INSTALLED: @@ -321,10 +318,10 @@ class BaseCreoleTest(MarkupTest): self.assertEqual(html, html_string, msg="rest2html") - def cross_compare_rest(self, rest_string, html_string, \ - strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): -# assert isinstance(textile_string, str) -# assert isinstance(html_string, str) + def cross_compare_rest(self, rest_string, html_string, + strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): + # assert isinstance(textile_string, str) + # assert isinstance(html_string, str) self.assertNotEqual(rest_string, html_string) rest_string, html_string = self.assert_html2rest( @@ -340,11 +337,11 @@ class BaseCreoleTest(MarkupTest): ) def cross_compare(self, - html_string, - creole_string=None, - textile_string=None, - rest_string=None, - strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): + html_string, + creole_string=None, + textile_string=None, + rest_string=None, + strip_lines=False, debug=False, parser_kwargs={}, emitter_kwargs={}): """ Cross compare with: * creole2html @@ -367,6 +364,7 @@ class BaseCreoleTest(MarkupTest): rest_string, html_string, strip_lines, debug, parser_kwargs, emitter_kwargs ) + if __name__ == '__main__': import doctest print(doctest.testmod()) |