From 30669eaee6c7941d9f7992b198a86f1d9d8e0772 Mon Sep 17 00:00:00 2001 From: Frank Smit Date: Fri, 6 Apr 2012 15:09:16 +0200 Subject: [PATCH] Use command line tidy tool. --- .travis.yml | 1 - tests/MarkdownTest_1.0.3/Auto links.text | 2 +- .../Links, shortcut references.html | 2 +- .../Links, shortcut references.text | 2 +- tests/minitest.py | 12 ++++++------ tests/misaka_test.py | 16 +++++++++++++--- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index bc30f0f..a9c6e20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ python: - 3.2 install: - - pip install pytidylib --use-mirrors - python setup.py install script: diff --git a/tests/MarkdownTest_1.0.3/Auto links.text b/tests/MarkdownTest_1.0.3/Auto links.text index abbc488..f85767b 100644 --- a/tests/MarkdownTest_1.0.3/Auto links.text +++ b/tests/MarkdownTest_1.0.3/Auto links.text @@ -10,4 +10,4 @@ With an ampersand: Auto-links should not occur here: `` - or here: \ No newline at end of file + or here: diff --git a/tests/MarkdownTest_1.0.3/Links, shortcut references.html b/tests/MarkdownTest_1.0.3/Links, shortcut references.html index bf81e93..0b5e1d6 100644 --- a/tests/MarkdownTest_1.0.3/Links, shortcut references.html +++ b/tests/MarkdownTest_1.0.3/Links, shortcut references.html @@ -3,7 +3,7 @@

This one has a line break.

-

This one has a line +

This one has a line break with a line-ending space.

this and the other

diff --git a/tests/MarkdownTest_1.0.3/Links, shortcut references.text b/tests/MarkdownTest_1.0.3/Links, shortcut references.text index 8c44c98..5dc43b8 100644 --- a/tests/MarkdownTest_1.0.3/Links, shortcut references.text +++ b/tests/MarkdownTest_1.0.3/Links, shortcut references.text @@ -7,7 +7,7 @@ This is the [simple case]. This one has a [line break]. -This one has a [line +This one has a [line break] with a line-ending space. [line break]: /foo diff --git a/tests/minitest.py b/tests/minitest.py index 42cd024..b266dcc 100644 --- a/tests/minitest.py +++ b/tests/minitest.py @@ -77,8 +77,8 @@ class TestCase(object): try: func() error = None - except Exception as e: - error = e.message + except AssertionError as e: + error = str(e) return Result(func.__name__, func.__doc__, error) self._tests.append(catch_exception) return catch_exception @@ -104,15 +104,15 @@ def runner(testcases, config={}): tests = testcase(config) if hasattr(tests, 'name'): - print '\n>> %s' % tests.name + print('\n>> %s' % tests.name) for result in tests.run(): name = result.name or result.func if result.error is not None: failed += 1 - print '%s ... FAILED\n\n%s\n' % (name, result.error) + print('%s ... FAILED\n\n%s\n' % (name, result.error)) else: passed += 1 - print '%s ... PASSED' % name + print('%s ... PASSED' % name) - print '\n\n%s passed; %s failed.' % (passed, failed) + print('\n\n%s passed; %s failed.' % (passed, failed)) diff --git a/tests/misaka_test.py b/tests/misaka_test.py index 39cd20d..e566d6a 100644 --- a/tests/misaka_test.py +++ b/tests/misaka_test.py @@ -3,9 +3,9 @@ import re from os import path from glob import glob +from subprocess import Popen, PIPE, STDOUT import misaka -from tidylib import tidy_document from misaka import Markdown, BaseRenderer, HtmlRenderer, \ SmartyPants, \ HTML_ESCAPE @@ -13,6 +13,13 @@ from misaka import Markdown, BaseRenderer, HtmlRenderer, \ from minitest import TestCase, ok, runner +def clean_html(dirty_html): + p = Popen(['tidy', '--show-body-only', '1', '--quiet', '1', '--show-warnings', '0'], + stdout=PIPE, stdin=PIPE, stderr=STDOUT) + return p.communicate(input=dirty_html.encode('utf-8'))[0].decode('utf-8') + + + class SmartyPantsTest(TestCase): name = 'SmartyPants' @@ -65,8 +72,11 @@ class MarkdownConformanceTest_10(TestCase): expected_html = fd.read() actual_html = self.r(text) - expected_result, errors = tidy_document(expected_html) - actual_result, errors = tidy_document(actual_html) + # expected_result, errors = tidy_document(expected_html) + # actual_result, errors = tidy_document(actual_html) + + expected_result = clean_html(expected_html) + actual_result = clean_html(actual_html) ok(actual_result).diff(expected_result)