[TIP] Writing Separate Functional Tests

Raphael Marvie raphael.marvie at lifl.fr
Thu Nov 22 00:57:18 PST 2007


On Nov 21, 2007, at 10:01 PM, Noah Gift wrote:
>>
>> Hey Noah,
>>
>> something like texttest (or 'diff') seems like the simplest way to  
>> go.
>> You could also use one of the bajillion XML parsers to make  
>> assertions
>> about the contents of the XML file.
>
> that is a good idea.  I was thinking to grand, but a simple diff is
> probably going to be fine for now, and when I need more control,
> parsing an XML file on an attribute by attribute basis will allow me
> to test verify what I am getting is what I expect.

Warning: An XML diff should not be limited to comparing similarly  
ordered XML documents. This takes a little bit more processing that  
text diff. So I think your attribute comparison scheme is ok, but for  
nodes it won't be as simple.

<doc>
   <node name="1" value="42" />
   <node name="2" value="meaning" />
</doc>

and

<doc>
   <node name="2" value="meaning" />
   <node value="42" name="1" />
</doc>

are similar.

http://www.logilab.org/859 may help you.

my 2 cents,

r.

--
Raphael Marvie, PhD                http://www.lifl.fr/~marvie/
Maître de Conférences / Associate Professor  @  LIFL -- IRCICA
Directeur du Master Informatique Professionnel spécialité IAGL
Head of Master's in Software Engineering     +33 3 28 77 85 83





More information about the testing-in-python mailing list