File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ html5lib is packaged with distutils. To install it use:
1111
1212You may wish to check that your installation has been a success by
1313running the testsuite. All the tests can be run by invoking
14- runtests.py in the tests/ directory
14+ runtests.py in the html5lib/ tests/ directory
1515
1616 = Usage =
1717
Original file line number Diff line number Diff line change 1- The testcases for the tokenizer require the use of simplejson
2- (http://cheeseshop.python.org/pypi/simplejson). Each testcase file can be run
3- directly through a python interpreter (e.g. python test_tokenizer.py).
1+ Each testcase file can be run directly through a python interpreter
2+ (e.g. python test_tokenizer.py).
3+
4+ Some testcases depend on the json module (available since Python 2.6),
5+ but will fall back to using simplejson if json is not available.
Original file line number Diff line number Diff line change 1- import os ,sys ,unittest
2- from support import simplejson , html5lib_test_files
1+ import os
2+ import sys
3+ import unittest
34
5+ try :
6+ import json
7+ except ImportError :
8+ import simplejson as json
9+
10+ from support import html5lib_test_files
411from html5lib import html5parser , sanitizer , constants
512
613class SanitizeTest (unittest .TestCase ):
714 def addTest (cls , name , expected , input ):
815 def test (self , expected = expected , input = input ):
916 expected = '' .join ([token .toxml () for token in html5parser .HTMLParser ().
1017 parseFragment (expected ).childNodes ])
11- expected = simplejson .loads (simplejson .dumps (expected ))
18+ expected = json .loads (json .dumps (expected ))
1219 self .assertEqual (expected , self .sanitize_html (input ))
1320 setattr (cls , name , test )
1421 addTest = classmethod (addTest )
@@ -73,7 +80,7 @@ def test_should_handle_astral_plane_characters(self):
7380
7481def buildTestSuite ():
7582 for filename in html5lib_test_files ("sanitizer" ):
76- for test in simplejson .load (file (filename )):
83+ for test in json .load (file (filename )):
7784 SanitizeTest .addTest ('test_' + test ['name' ], test ['output' ], test ['input' ])
7885
7986 return unittest .TestLoader ().loadTestsFromTestCase (SanitizeTest )
You can’t perform that action at this time.
0 commit comments