Skip to content
Browse files

Progress towards accomodating Python 2.2

  • Loading branch information...
1 parent f338e29 commit 366fe8b36771ac508ef937ea1fcf6bd885850191 Sam Ruby committed
Showing with 15 additions and 8 deletions.
  1. +1 −1 planet/reconstitute.py
  2. +2 −1 planet/shell/xslt.py
  3. +4 −4 tests/test_apply.py
  4. +8 −2 tests/test_spider.py
View
2 planet/reconstitute.py
@@ -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 """
View
3 planet/shell/xslt.py
@@ -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)
View
8 tests/test_apply.py
@@ -44,8 +44,8 @@ def test_apply_asf(self):
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 @@ def test_apply_fancy(self):
# 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)
View
10 tests/test_spider.py
@@ -28,13 +28,19 @@ def tearDown(self):
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')

0 comments on commit 366fe8b

Please sign in to comment.
Something went wrong with that request. Please try again.