From: <cg...@us...> - 2006-10-17 01:27:48
|
Revision: 2960 http://svn.sourceforge.net/jython/?rev=2960&view=rev Author: cgroves Date: 2006-10-16 18:27:40 -0700 (Mon, 16 Oct 2006) Log Message: ----------- added locator tests from test_sax2 in pyxml Modified Paths: -------------- trunk/jython/Lib/test/test_sax.py Modified: trunk/jython/Lib/test/test_sax.py =================================================================== --- trunk/jython/Lib/test/test_sax.py 2006-10-16 01:24:09 UTC (rev 2959) +++ trunk/jython/Lib/test/test_sax.py 2006-10-17 01:27:40 UTC (rev 2960) @@ -442,7 +442,40 @@ return result.getvalue() == xml_test_out +# ===== Locator support +class LocatorTest(XMLGenerator): + def __init__(self, out=None, encoding="iso-8859-1"): + XMLGenerator.__init__(self, out, encoding) + self.location = None + + def endDocument(self): + XMLGenerator.endDocument(self) + self.location = Location(self._locator) + +def test_expat_locator_noinfo(): + result = StringIO() + xmlgen = LocatorTest(result) + parser = make_parser() + parser.setContentHandler(xmlgen) + + parser.parse(StringIO("<doc></doc>")) + + return xmlgen.location.getSystemId() is None and \ + xmlgen.location.getPublicId() is None and \ + xmlgen.location.getLineNumber() == 1 + +def test_expat_locator_withinfo(): + result = StringIO() + xmlgen = LocatorTest(result) + parser = make_parser() + parser.setContentHandler(xmlgen) + parser.parse(findfile("test.xml")) + + return xmlgen.location.getSystemId().endswith(findfile("test.xml")) and \ + xmlgen.location.getPublicId() is None + + # =========================================================================== # # error reporting This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2006-12-31 21:16:53
|
Revision: 3035 http://svn.sourceforge.net/jython/?rev=3035&view=rev Author: cgroves Date: 2006-12-31 13:16:52 -0800 (Sun, 31 Dec 2006) Log Message: ----------- swap \ for / in the path for checking against system id since its a URL Modified Paths: -------------- trunk/jython/Lib/test/test_sax.py Modified: trunk/jython/Lib/test/test_sax.py =================================================================== --- trunk/jython/Lib/test/test_sax.py 2006-12-31 21:16:10 UTC (rev 3034) +++ trunk/jython/Lib/test/test_sax.py 2006-12-31 21:16:52 UTC (rev 3035) @@ -470,9 +470,16 @@ xmlgen = LocatorTest(result) parser = make_parser() parser.setContentHandler(xmlgen) - parser.parse(findfile("test.xml")) + 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': + testfile = testfile.replace('\\', '/') - return xmlgen.location.getSystemId().endswith(findfile("test.xml")) and \ + return xmlgen.location.getSystemId().endswith(testfile) and \ xmlgen.location.getPublicId() is None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-01-25 01:57:08
|
Revision: 3065 http://svn.sourceforge.net/jython/?rev=3065&view=rev Author: cgroves Date: 2007-01-24 17:57:07 -0800 (Wed, 24 Jan 2007) Log Message: ----------- grab the location in setDocumentLocation rather than in endDocument as the locator is only guaranteed to be valid when its given, and in Java 6 it changed so that it's cleared out after parsing is finished Modified Paths: -------------- trunk/jython/Lib/test/test_sax.py Modified: trunk/jython/Lib/test/test_sax.py =================================================================== --- trunk/jython/Lib/test/test_sax.py 2007-01-24 06:33:00 UTC (rev 3064) +++ trunk/jython/Lib/test/test_sax.py 2007-01-25 01:57:07 UTC (rev 3065) @@ -449,9 +449,9 @@ XMLGenerator.__init__(self, out, encoding) self.location = None - def endDocument(self): - XMLGenerator.endDocument(self) - self.location = Location(self._locator) + def setDocumentLocator(self, locator): + XMLGenerator.setDocumentLocator(self, locator) + self.location = Location(self._locator) def test_expat_locator_noinfo(): result = StringIO() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-02-11 19:19:16
|
Revision: 3101 http://svn.sourceforge.net/jython/?rev=3101&view=rev Author: cgroves Date: 2007-02-11 11:19:14 -0800 (Sun, 11 Feb 2007) Log Message: ----------- skip the expat tests on Java 1.4 since the xml parser from that version of java isn't quite as advanced as one would hope. Java 5 and 6 have an improved parser and pass the expat tests fine. Modified Paths: -------------- trunk/jython/Lib/test/test_sax.py Modified: trunk/jython/Lib/test/test_sax.py =================================================================== --- trunk/jython/Lib/test/test_sax.py 2007-02-11 18:46:16 UTC (rev 3100) +++ trunk/jython/Lib/test/test_sax.py 2007-02-11 19:19:14 UTC (rev 3101) @@ -707,9 +707,16 @@ outf.write(result.getvalue()) outf.close() +import sys +java_14 = sys.platform.startswith("java1.4") +del sys + items = locals().items() items.sort() for (name, value) in items: + if name.startswith('test_expat') and java_14: + #skip expat tests on java14 since the crimson parser is so crappy + continue if name[:5] == "test_": confirm(value(), name) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |