Use command line tidy tool.
This commit is contained in:
parent
d9af944aef
commit
30669eaee6
|
@ -5,7 +5,6 @@ python:
|
|||
- 3.2
|
||||
|
||||
install:
|
||||
- pip install pytidylib --use-mirrors
|
||||
- python setup.py install
|
||||
|
||||
script:
|
||||
|
|
|
@ -10,4 +10,4 @@ With an ampersand: <http://example.com/?foo=1&bar=2>
|
|||
|
||||
Auto-links should not occur here: `<http://example.com/>`
|
||||
|
||||
or here: <http://example.com/>
|
||||
or here: <http://example.com/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<p>This one has a <a href="/foo">line
|
||||
break</a>.</p>
|
||||
|
||||
<p>This one has a <a href="/foo">line
|
||||
<p>This one has a <a href="/foo">line
|
||||
break</a> with a line-ending space.</p>
|
||||
|
||||
<p><a href="/that">this</a> and the <a href="/other">other</a></p>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue