[XML-SIG] DC DOM tests (Was: Roadmap document - finally!)

Martijn Pieters mj@digicool.com
Mon, 19 Feb 2001 11:48:27 +0100


--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Feb 17, 2001 at 12:39:43PM -0700, Uche Ogbuji wrote:
> >   This might be a good time to note that some of us at Digital
> >   Creations (mostly Martijn Pieters) have created a DOM test suite
> >   that can test for DOM Level 1 & 2 compliance of the "Core" and "XML"
> >   features (so far); we hope to make this a standard test for Python
> >   DOM implementations.
> >
> >   The XML crew at DC will have to talk about how to make the suite
> >   readily available, but I hope it won't be too far off.
> 
> Lars already has such a beast.  Does your test suite incorporate or work
> with his?

I cannot find any references to Lars' test suite; so I don't know if it
will work with his.

Maybe a small overview of what our suite does may help:

- We use PyUnit; the whole Zope testing framework is based on it.

- The suite tests only for DOM compliance, nothing implementation specific
  should be in there. There are some python binding tests, we may want to
  move those out.

- The tests are organized by interface; the test classes follow the same
  inheritence structure as the interfaces in the DOM specs. So the
  CDATASection interface tests inherit the Text interface tests, which in
  turn inherit the Node interface tests. This has made the tests far more
  complete.

- The test suites are further organised by feature set and compliance
  level. There are seperate files for Core level 1 and Core level 2 tests,
  and the same for the XML tests. Adding tests for a different DOM feature
  is trivial.

- The "Core" feature is almost fully tested now; only some
  NO_MODIFICATION_ALLOWED and default attribute situations aren't tested
  for yet.

- The "XML" feature tests are still missing Entity and Notation Node
  tests; adding these is my next priority.

- I have made a first go at tests for the "Traversal" feature; only the
  DocumentTraversal interface is tested.

- DOMString and text manipulating interface methods are not tested beyond
  ASCII text due to an implementation limitation of ParsedXML.DOM. So,
  implementations will not be tested if text is correctly treated when
  multi-byte UTF-16 characters are involved.

- Currently, about 650 tests will be run on a DOM supporting all the
  features we can test for.

To obtain the tests, you'll have to do a CVS checkout from cvs.zope.org:

  % cvs -d :pserver:anonymous@cvs.zope.org:/cvs-repository login
  (Logging in to anonymous@cvs.zope.org)
  CVS Password: anonymous                 # So the password is 'anonymous'

  % cvs -z7 -d :pserver:anonymous@cvs.zope.org:/cvs-repository checkout \
            -d DOMTests Products/DC/ParsedXML/test/domapi

To test a DOM implementation, you need to pass in your DOMImplementation
object, and a parsing method that will create a DOM tree for a given XML
string. The latter is used to create Notation, Entity and default Attr
Nodes, which you can't produce with the current DOM API.

I attached a sample script which tests the PyXML DOM; it assumes you made
a stand-alone checkout of the tests as described above into a DOMTests
directory on the Python path. It requires a patched PyXML that will return
true on DOMImplementation.hasFeature('Core', '2.0') (fixed in the
FourThought CVS, I believe). See bug #132683 on SourceForge (now closed).

When running the tests, there are three that trigger an infinite loop in
the PyXML 0.6.3 suite. When a test seems to take too long, a keyboard
interrupt will cause PyUnit to skip to the next test (and log a traceback
on KeyboardInterrupt for the offending test).

-- 
Martijn Pieters
| Software Engineer  mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="test_PyXMLDOM.py"

#!/usr/bin/env python
from xml.dom import implementation
from xml.dom.ext.reader.Sax2 import Reader
from DOMTests import DOMImplementationTestSuite

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

def Sax2ParseString(self, xml):
    file = StringIO(xml)
    return Reader().fromStream(file)

def test_suite():
    """Create a test suite for a DOM implementation."""
    return DOMImplementationTestSuite(implementation, Sax2ParseString)

if __name__ == '__main__':
    import unittest
    unittest.TextTestRunner().run(test_suite())

--XsQoSWH+UP9D9v3l--