Ian Bicking: the old part of his blog

XML and doctest

After writing htmlgen, I then went about using it with a new module formgen (based on an old module that was more complicated). I kept the tests, which were based on doctest. But that's annoying, because all the attributes get moved around, and the output has no indentation or whitespace, and that's not very good documentation (and not very easy to write either).

DataTest (now defunct since py.test is better) had a module that allowed you to plug in different comparisons, like one that did simplistic HTML/XML parsing and did fuzzy comparisons based on that. Luckily that's not necessary anymore, because doctest in Python 2.4 includes the necessary documented hooks to do it yourself. (That doctest version still works fine in earlier versions of Python.)

So I wrote a module doctest_xml_compare that attempts to compare output against input on that basis. It's pretty rough, but it mostly does the job. It also has a comparison function for ElementTree trees that gives you a little feedback on the difference between two trees (so you don't have to puzzle your way through looking for a slight difference).

Created 24 Feb '05
Modified 24 Feb '05


This is off topic but... I've always had a strange problem with the recent changes RSS feed on this Wiki. I get a lot of entries titled simple "This Wiki". When clicked on, I get this error message;

blog.ianbickingorghttp could not be found. Please check the name and try again.

I'm using Sage (an RSS plug-in for Firefox). It's been going on for a long time. Is it just me?

# joeg