[Twisted-Python] trial testing messages

Jean-Paul Calderone exarkun at divmod.com
Wed Nov 19 09:01:35 MST 2008


On Wed, 19 Nov 2008 15:43:36 +0100, Gabriel Rossetti <gabriel.rossetti at arimaz.com> wrote:
>Hello,
>
>I am writing unit tests using trial. I am trying to make sure that the 
>received messages are processed correctly and the output messages are 
>correct. I tried using toXml(), but the XML attributes aren't necessaraly in 
>the correct order, so a string comparison doesn't work. I had originally 
>submitted a patch to allow domish.Element to be compared (ticket #3344), but 
>my patch isn't liked. So my question is, how may I test this?

If you keep agitating about #3344, then it should get resolved eventually.
Commenting on the ticket is good, but if that doesn't get you anywhere, you
might want to find people on IRC or follow up on the mailing list.

That aside, you should be able to use the solution you proposed for
inclusion in Twisted without actually having Twisted change.  You can
just implement comparison as a free function which takes two elements
and implements the logic you're interested in.  You'll have to use
TestCase.assertTrue(equals(a, b)) instead of TestCase.assertEqual(a, b)
but that's a pretty minor difference.  Hopefully this will be an interim
solution until domish.Elements gain the feature you want, but this might
serve you elsewhere in a more long-term fashion.  There can only be one
definition of equality for a particular type.  It is necessarily the case
that this definition won't always be what everyone wants to use.

Jean-Paul




More information about the Twisted-Python mailing list