Lines 5-10
Link Here
|
5 |
|
3 |
|
6 |
class TidyTestCase(unittest.TestCase): |
4 |
class TidyTestCase(unittest.TestCase): |
7 |
def __init__(self, *args, **kwargs): |
5 |
def __init__(self, *args, **kwargs): |
|
|
6 |
super(unittest.TestCase, self).__init__(*args, **kwargs) |
7 |
self._shared = False |
8 |
self._parents = [] |
9 |
|
8 |
foo = u'''<html> |
10 |
foo = u'''<html> |
9 |
<h1>woot</h1> |
11 |
<h1>woot</h1> |
10 |
<hr> |
12 |
<hr> |
Lines 14-28
Link Here
|
14 |
</body> |
18 |
</body> |
15 |
</html> |
19 |
</html> |
16 |
'''.encode('utf8') |
20 |
'''.encode('utf8') |
17 |
file('foo.htm', 'w').write(foo) |
21 |
file('foo.htm', 'w').write(foo) |
18 |
self.input1 = "<html><script>1>2</script>" |
22 |
self.input1 = "<html><script>1>2</script>" |
19 |
self.input2 = "<html>\n" + "<p>asdkfjhasldkfjhsldjas\n" * 100 |
23 |
self.input2 = "<html>\n" + "<p>asdkfjhasldkfjhsldjas\n" * 100 |
20 |
|
24 |
|
21 |
def defaultDocs(self): |
25 |
def defaultDocs(self): |
22 |
doc1 = tidy.parseString(self.input1) |
26 |
doc1 = tidy.parseString(self.input1) |
23 |
doc2 = tidy.parseString(self.input2) |
27 |
doc2 = tidy.parseString(self.input2) |
24 |
doc3 = tidy.parse("foo.htm") |
28 |
doc3 = tidy.parse("../foo.htm") |
25 |
doc4 = tidy.parse("bar.htm") # doesn't exist |
29 |
doc4 = tidy.parse("bar.htm") # doesn't exist |
26 |
return (doc1, doc2, doc3, doc4) |
30 |
return (doc1, doc2, doc3, doc4) |
27 |
|
31 |
|
28 |
def test_badOptions(self): |
32 |
def test_badOptions(self): |
Lines 37-43
Link Here
|
37 |
self.fail("Invalid option %s should have raised an error" % |
41 |
self.fail("Invalid option %s should have raised an error" % |
38 |
repr(dct)) |
42 |
repr(dct)) |
39 |
def test_encodings(self): |
43 |
def test_encodings(self): |
40 |
foo = file('foo.htm').read().decode('utf8').encode('ascii', |
44 |
foo = file('../foo.htm').read().decode('utf8').encode('ascii', |
41 |
'xmlcharrefreplace') |
45 |
'xmlcharrefreplace') |
42 |
doc1u = tidy.parseString(foo, input_encoding='ascii', |
46 |
doc1u = tidy.parseString(foo, input_encoding='ascii', |
43 |
output_encoding='latin1') |
47 |
output_encoding='latin1') |
Lines 64-70
Link Here
|
64 |
## self.failIf(len(doc2.errors)>1) # FIXME - tidylib doesn't |
68 |
## self.failIf(len(doc2.errors)>1) # FIXME - tidylib doesn't |
65 |
## # support this? |
69 |
## # support this? |
66 |
self.failUnless(str(doc2).find('\n') < 0) |
70 |
self.failUnless(str(doc2).find('\n') < 0) |
67 |
doc3 = tidy.parse('foo.htm', char_encoding='utf8', |
71 |
doc3 = tidy.parse('../foo.htm', char_encoding='utf8', |
68 |
alt_text='foo') |
72 |
alt_text='foo') |
69 |
self.failUnless(str(doc3).find('alt="foo"') >= 0) |
73 |
self.failUnless(str(doc3).find('alt="foo"') >= 0) |
70 |
self.failUnless(str(doc3).find('\xc3\xa9') >= 0) |
74 |
self.failUnless(str(doc3).find('\xc3\xa9') >= 0) |