diff --git a/planet/reconstitute.py b/planet/reconstitute.py index eb1548a..f578c7e 100644 --- a/planet/reconstitute.py +++ b/planet/reconstitute.py @@ -35,7 +35,7 @@ def createTextElement(parent, name, value): def invalidate(c): """ replace invalid characters """ return '\xef\xbf\xbd' % \ - 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 """ diff --git a/planet/shell/xslt.py b/planet/shell/xslt.py index 6757d8f..1e6de03 100644 --- a/planet/shell/xslt.py +++ b/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) diff --git a/tests/test_apply.py b/tests/test_apply.py index e035ab2..e737ee0 100644 --- a/tests/test_apply.py +++ b/tests/test_apply.py @@ -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('

test planet

' in html) - self.assertTrue('

Venus

' - in html) + self.assertTrue(html.find('

test planet

')>=0) + self.assertTrue(html.find( + '

Venus

')>=0) diff --git a/tests/test_spider.py b/tests/test_spider.py index bade72a..3549392 100644 --- a/tests/test_spider.py +++ b/tests/test_spider.py @@ -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')