Progress towards accomodating Python 2.2
This commit is contained in:
parent
f338e293ae
commit
366fe8b367
@ -35,7 +35,7 @@ def createTextElement(parent, name, value):
|
||||
def invalidate(c):
|
||||
""" replace invalid characters """
|
||||
return '<acronym title="U+%s">\xef\xbf\xbd</acronym>' % \
|
||||
hex(ord(c.group(0)))[2:].rjust(4,'0')
|
||||
('000' + hex(ord(c.group(0)))[2:])[-4:]
|
||||
|
||||
def ncr2c(value):
|
||||
""" convert numeric character references to characters """
|
||||
|
@ -13,7 +13,8 @@ def run(script, doc, output_file=None):
|
||||
# otherwise, use the command line interface
|
||||
dom = None
|
||||
import warnings
|
||||
warnings.simplefilter('ignore', RuntimeWarning)
|
||||
if hasattr(warnings, 'simplefilter'):
|
||||
warnings.simplefilter('ignore', RuntimeWarning)
|
||||
docfile = os.tmpnam()
|
||||
file = open(docfile,'w')
|
||||
file.write(doc)
|
||||
|
@ -44,8 +44,8 @@ class ApplyTest(unittest.TestCase):
|
||||
content += 1
|
||||
if div.getAttribute('xml:lang') == 'en-us': lang += 1
|
||||
html.close()
|
||||
self.assertEqual(3, lang)
|
||||
self.assertEqual(12, content)
|
||||
self.assertEqual(3, lang)
|
||||
|
||||
def test_apply_fancy(self):
|
||||
config.load(configfile % 'fancy')
|
||||
@ -59,6 +59,6 @@ class ApplyTest(unittest.TestCase):
|
||||
|
||||
# verify that index.html is well formed, has content, and xml:lang
|
||||
html = open(os.path.join(workdir, 'index.html')).read()
|
||||
self.assertTrue('<h1>test planet</h1>' in html)
|
||||
self.assertTrue('<h4><a href="http://example.com/2">Venus</a></h4>'
|
||||
in html)
|
||||
self.assertTrue(html.find('<h1>test planet</h1>')>=0)
|
||||
self.assertTrue(html.find(
|
||||
'<h4><a href="http://example.com/2">Venus</a></h4>')>=0)
|
||||
|
@ -28,13 +28,19 @@ class SpiderTest(unittest.TestCase):
|
||||
def test_filename(self):
|
||||
self.assertEqual('./example.com,index.html',
|
||||
filename('.', 'http://example.com/index.html'))
|
||||
self.assertEqual('./xn--8ws00zhy3a.com',
|
||||
filename('.', u'http://www.\u8a79\u59c6\u65af.com/'))
|
||||
self.assertEqual('./planet.intertwingly.net,2006,testfeed1,1',
|
||||
filename('.', u'tag:planet.intertwingly.net,2006:testfeed1,1'))
|
||||
self.assertEqual('./00000000-0000-0000-0000-000000000000',
|
||||
filename('.', u'urn:uuid:00000000-0000-0000-0000-000000000000'))
|
||||
|
||||
# Requires Python 2.3
|
||||
try:
|
||||
import encodings.idna
|
||||
except:
|
||||
return
|
||||
self.assertEqual('./xn--8ws00zhy3a.com',
|
||||
filename('.', u'http://www.\u8a79\u59c6\u65af.com/'))
|
||||
|
||||
def test_spiderFeed(self):
|
||||
config.load(configfile)
|
||||
spiderFeed(testfeed % '1b')
|
||||
|
Loading…
x
Reference in New Issue
Block a user