[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful/tests - test_contentworkflow.py:1.4

Tres Seaver tseaver at zope.com
Sun Aug 3 23:00:07 EDT 2003


On Sat, 2003-08-02 at 21:33, Philipp von Weitershausen wrote:

> Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful/tests
> In directory cvs.zope.org:/tmp/cvs-serv17263/src/zope/app/workflow/stateful/tests
> 
> Modified Files:
> 	test_contentworkflow.py 
> Log Message:
> The ContentWorkflowsManager returns interfaces not in any particular order
> since they come out of dict.keys(). Thus, accept the two interfaces in the
> test in either order.
> 
> This is situation is really tricky. For the original committer of the test,
> it probably worked 100% of the time, while for others (like me), it always
> returned a failure (I wonder what the cause is -- big endian vs. small
> endian?). What can we do to avoid situations like these?
> 
> 
> === Zope3/src/zope/app/workflow/stateful/tests/test_contentworkflow.py 1.3 => 1.4 ===
> --- Zope3/src/zope/app/workflow/stateful/tests/test_contentworkflow.py:1.3	Tue Jul 29 20:00:28 2003
> +++ Zope3/src/zope/app/workflow/stateful/tests/test_contentworkflow.py	Sat Aug  2 21:33:10 2003
> @@ -150,9 +150,9 @@
>  
>      def test_getInterfacesForProcessName(self):
>          manager = self.getManager()
> -        self.assertEqual(
> -            manager.getInterfacesForProcessName(u'default'),
> -            (IFace2, IFace1))
> +        ifaces = manager.getInterfacesForProcessName(u'default')
> +        self.assert_(ifaces == (IFace2, IFace1) or
> +                     ifaces == (IFace1, IFace2))

This is how a do an order-insensitive test:

           ifaces = manager.getInterfacesForProcessName(u'default')
           self.assertEqual(len(ifaces), 2)
           for iface in [IFace1, IFace2]:  # add more if needed
               self.failUnless(iface in ifaces)

Here, all we have asserted is that 'ifaces' is a sequence, consisting
of the items we care about:  it could chante to be a list, and the
test would still pass;  it could even be a fancier iterator instance
of some kind.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com




More information about the Zope3-Checkins mailing list