[CMF-checkins] CVS: CMF/CMFCore/tests - test_ActionProviderBase.py:1.7
Tres Seaver
tseaver@zope.com
Wed, 3 Jul 2002 10:07:41 -0400
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv22575/CMFCore/tests
Modified Files:
test_ActionProviderBase.py
Log Message:
- ActionInformation:
o Added 'clone' method.
- ActionProviderBase:
o Always clone actions when modifying the list, to avoid sharing
action instances between the class (where they are regenerated
on restart) and its instance (where the actions are persistent).
=== CMF/CMFCore/tests/test_ActionProviderBase.py 1.6 => 1.7 ===
), )
+class DummyAction:
+
+ def __init__( self, value ):
+ self.value = value
+
+ def clone( self ):
+ return self.__class__( self.value )
+
+ def __cmp__( self, other ):
+ return ( cmp( type( self ), type( other ) )
+ or cmp( self.__class__, other.__class__ )
+ or cmp( self.value, other.value )
+ or 0
+ )
class ActionProviderBaseTests(unittest.TestCase):
@@ -96,10 +110,10 @@
def test_deleteActions( self ):
apb = self._makeProvider()
- apb._actions = [ '0', '1', '2' ] # fake out for testing
+ apb._actions = tuple( map( DummyAction, [ '0', '1', '2' ] ) )
apb.deleteActions( selections=(0,2) )
self.assertEqual( len( apb._actions ), 1 )
- self.failUnless( '1' in apb._actions )
+ self.failUnless( DummyAction('1') in apb._actions )
def test_DietersNastySharingBug( self ):