[CMF-checkins] CVS: CMF/CMFDefault/tests - test_Discussions.py:1.9

Chris Withers chrisw@nipltd.com
Tue, 29 Jan 2002 07:18:14 -0500


Update of /cvs-repository/CMF/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv18970/CMFDefault/tests

Modified Files:
	test_Discussions.py 
Log Message:
A bit of refactoring and a couple of fixes which mean the tests still pass even when an obejct called 'test' already exists in the test ZODB.

=== CMF/CMFDefault/tests/test_Discussions.py 1.8 => 1.9 ===
         self._oldPolicy = SecurityManager.setSecurityPolicy(self._policy)
         self.connection = Zope.DB.open()
-        self.root = self.connection.root()[ 'Application' ]
+        self.root = root = self.connection.root()[ 'Application' ]
         self.root._setObject( 'portal_discussion', DiscussionTool() )
         self.discussion_tool = self.root.portal_discussion
         self.root._setObject( 'portal_catalog', CatalogTool() )
@@ -47,6 +47,10 @@
         self.workflow_tool = self.root.portal_workflow
         self.root._setObject( 'portal_types', TypesTool() )
         types_tool = self.types_tool = self.root.portal_types
+        try: root._delObject('test')
+        except AttributeError: pass
+        root._setObject( 'test', Document( 'test' ) )
+            
     
     def tearDown( self ):
         del self.types_tool
@@ -62,7 +66,6 @@
 
     def test_policy( self ):
 
-        self.root._setObject( 'test', Document( 'test' ) )
         test = self.root.test
         self.assertRaises( DiscussionNotAllowed
                          , self.discussion_tool.getDiscussionFor
@@ -107,7 +110,6 @@
         assert test.talkback
     
     def test_nestedReplies( self ):
-        self.root._setObject( 'test', Document( 'test' ) )
         test = self.root.test
         test.allow_discussion = 1
         talkback = self.discussion_tool.getDiscussionFor( test )
@@ -157,7 +159,6 @@
 
     def test_itemCatloguing( self ):
 
-        self.root._setObject( 'test', Document( 'test' ) )
         test = self.root.test
         catalog = self.catalog_tool._catalog
         test.allow_discussion = 1
@@ -191,7 +192,6 @@
 
     def test_deletePropagation( self ):
 
-        self.root._setObject( 'test', Document( 'test' ) )
         test = self.root.test
 
         test.allow_discussion = 1