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:
|
||||
|
|
|
@ -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