From: <pj...@us...> - 2009-04-11 01:11:11
|
Revision: 6214 http://jython.svn.sourceforge.net/jython/?rev=6214&view=rev Author: pjenvey Date: 2009-04-11 01:11:10 +0000 (Sat, 11 Apr 2009) Log Message: ----------- fix test_sax when running under a path name with spaces Modified Paths: -------------- trunk/jython/Lib/test/test_sax.py Modified: trunk/jython/Lib/test/test_sax.py =================================================================== --- trunk/jython/Lib/test/test_sax.py 2009-04-11 00:25:21 UTC (rev 6213) +++ trunk/jython/Lib/test/test_sax.py 2009-04-11 01:11:10 UTC (rev 6214) @@ -2,6 +2,7 @@ # regression test for SAX 2.0 # $Id: test_sax.py,v 1.13 2004/03/20 07:46:04 fdrake Exp $ +import urllib from xml.sax import handler, make_parser, ContentHandler, \ SAXException, SAXReaderNotAvailable, SAXParseException try: @@ -13,7 +14,7 @@ XMLFilterBase, Location from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl from cStringIO import StringIO -from test.test_support import verbose, TestFailed, findfile +from test.test_support import is_jython, verbose, TestFailed, findfile # ===== Utilities @@ -472,28 +473,17 @@ parser.setContentHandler(xmlgen) testfile = findfile("test.xml") parser.parse(testfile) - #In Jython, the system id is a URL with forward slashes, and under Windows - #findfile returns a path with backslashes, so replace the backslashes with - #forward - import os - if os.name == 'java': + if is_jython: + # In Jython, the system id is a URL with forward slashes, and + # under Windows findfile returns a path with backslashes, so + # replace the backslashes with forward testfile = testfile.replace('\\', '/') - t = xmlgen.location.getSystemId().endswith(testfile) and \ + # XXX: may not match getSystemId when the filename contains funky + # characters (like ':') + expected = urllib.quote(testfile) + return xmlgen.location.getSystemId().endswith(expected) and \ xmlgen.location.getPublicId() is None - if not t: - print 'os.name: %s' % os.name - print 'systemId (%s): %s publicId (%s): %s' % \ - (type(xmlgen.location.getSystemId()), xmlgen.location.getSystemId(), - type(xmlgen.location.getPublicId()), xmlgen.location.getPublicId()) - content = open(testfile).read() - print '------- contents of %s ---------' % testfile - print content - print '------- end contents of %s ---------' % testfile - print '------- repr ---------' - print repr(content) - print '------- end repr ---------' - return t # =========================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |