Re: Python version of XMLUnit?

2006-03-07 Thread uche . ogbuji
Kent Johnson wrote:
> I have found XMLUnit to be very helpful for testing Java and Jython code
> that generates XML. At its heart XMLUnit is an XML-aware diff - it
> parses expected and actual XML and pinpoints any differences. It is
> smart enough to ignore things like attribute order, different quoting
> and escaping styles, and insignificant whitespace.
>
> Now I am working on a CPython project and have a similar need. Is there
> any comparable tool for Python? Basically I'm looking for a tool to
> compare XML and show diffs in an intelligible fashion that is usable
> from Python unit tests (using py.test, if it matters).

One possible approach is to use c14n to in effect normalize the XML so
that you can use regular text compare.  This is not as sophisticated as
a full XML diff, but it's definitely a viable approach for testing.

For those who migh tbe interested in that approach, learn more about
c14n here:

http://www.ibm.com/developerworks/xml/library/x-c14n/

It includes a brief example using the c14n module in PyXML

http://pyxml.sourceforge.net/

I also recently checked in c14n capability for 4Suite.  It offers the
same level of coverage as PyXML's, but operates in streaming, rather
than DOM mode.

http://4suite.org/

4Suite also contains in its test suite routines (TreeCompare) for
comparing XMl and HTML while ignoring non-significant syntactic
variations.

Certainly full xmldiff is very useful.  One nice thing about LogiLabs's
app is that it  can output XUpdate, which could be used with, say
4Suite's 4XUpdate to apply a patch to another document.

--
Uche Ogbuji   Fourthought, Inc.
http://uche.ogbuji.nethttp://fourthought.com
http://copia.ogbuji.net   http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python version of XMLUnit?

2006-03-06 Thread Kent Johnson
Benjamin Niemann wrote:
> http://www.logilab.org/projects/xmldiff
> 
> You'd still have to integrate this into your test framework though...

Thanks, that looks promising.
> 
> And I'll have a look at XMLUnit - seem's like something I could use for my
> current project ;)

XMLUnit is *very* useful. For example here is a typical assertion error:
[different] Expected attribute value '1500' but was '150' - comparing 
 at 
/PageItem[1]/HotspotModelItem[1]/@height to  at /PageItem[1]/HotspotModelItem[1]/@height

Notice how it shows you exactly the error including XPath expressions to 
the node containing the error!

In Jython I use unittest, not JUnit, so instead of subclassing 
XMLTestCase I call the static methods of XLMAssert from my test cases.

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python version of XMLUnit?

2006-03-06 Thread Benjamin Niemann
Kent Johnson wrote:

> I have found XMLUnit to be very helpful for testing Java and Jython code
> that generates XML. At its heart XMLUnit is an XML-aware diff - it
> parses expected and actual XML and pinpoints any differences. It is
> smart enough to ignore things like attribute order, different quoting
> and escaping styles, and insignificant whitespace.
> 
> Now I am working on a CPython project and have a similar need. Is there
> any comparable tool for Python? Basically I'm looking for a tool to
> compare XML and show diffs in an intelligible fashion that is usable
> from Python unit tests (using py.test, if it matters).

http://www.logilab.org/projects/xmldiff

You'd still have to integrate this into your test framework though...

And I'll have a look at XMLUnit - seem's like something I could use for my
current project ;)

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Python version of XMLUnit?

2006-03-05 Thread Kent Johnson
I have found XMLUnit to be very helpful for testing Java and Jython code 
that generates XML. At its heart XMLUnit is an XML-aware diff - it 
parses expected and actual XML and pinpoints any differences. It is 
smart enough to ignore things like attribute order, different quoting 
and escaping styles, and insignificant whitespace.

Now I am working on a CPython project and have a similar need. Is there 
any comparable tool for Python? Basically I'm looking for a tool to 
compare XML and show diffs in an intelligible fashion that is usable 
from Python unit tests (using py.test, if it matters).

Thanks,
Kent

http://xmlunit.sourceforge.net/
-- 
http://mail.python.org/mailman/listinfo/python-list