[CMF-checkins] CVS: Products/CMFCore/tests -
test_CMFCatalogAware.py:1.1.4.4
test_DirectoryView.py:1.19.10.8 test_FSSecurity.py:1.7.14.5
test_TypesTool.py:1.32.2.8
Tres Seaver
tseaver at palladion.com
Fri Jul 15 22:31:32 EDT 2005
Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv15086/CMFCore/tests
Modified Files:
Tag: CMF-1_5-branch
test_CMFCatalogAware.py test_DirectoryView.py
test_FSSecurity.py test_TypesTool.py
Log Message:
- Added testing framework to suppress / examine output from warnings
module and from zLOG (cleaner than just 'filterwarnings', which was
leaving nasty side effects).
=== Products/CMFCore/tests/test_CMFCatalogAware.py 1.1.4.3 => 1.1.4.4 ===
--- Products/CMFCore/tests/test_CMFCatalogAware.py:1.1.4.3 Fri Jun 3 13:11:41 2005
+++ Products/CMFCore/tests/test_CMFCatalogAware.py Fri Jul 15 22:30:31 2005
@@ -30,6 +30,7 @@
from OFS.SimpleItem import SimpleItem
from Products.ZCatalog import CatalogBrains
from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
+from Products.CMFCore.tests.base.testcase import LogInterceptor
def physicalpath(ob):
@@ -100,7 +101,7 @@
self.notified = True
-class CMFCatalogAwareTests(unittest.TestCase):
+class CMFCatalogAwareTests(unittest.TestCase, LogInterceptor):
def setUp(self):
self.root = DummyRoot('')
@@ -109,6 +110,9 @@
self.site._setObject('portal_catalog', DummyCatalog())
self.site.foo = TheClass('foo')
+ def tearDown(self):
+ self._ignore_log_errors
+
def test_indexObject(self):
foo = self.site.foo
cat = self.site.portal_catalog
@@ -178,15 +182,18 @@
def test_reindexObjectSecurity_missing_raise(self):
# Exception raised for missing object (Zope 2.8 brains)
+ self._catch_log_errors()
foo = self.site.foo
missing = TheClass('missing').__of__(foo)
missing.GETOBJECT_RAISES = True
cat = self.site.portal_catalog
cat.setObs([foo, missing])
self.assertRaises(NotFound, foo.reindexObjectSecurity)
+ self.failUnless( self.logged is None ) # no logging due to raise
def test_reindexObjectSecurity_missing_noraise(self):
# Raising disabled
+ self._catch_log_errors()
foo = self.site.foo
missing = TheClass('missing').__of__(foo)
missing.GETOBJECT_RAISES = False
@@ -200,6 +207,7 @@
def test_reindexObjectSecurity_missing_oldbrain(self):
# Missing object is swallowed by old Zope brains
+ self._catch_log_errors()
self.site.portal_catalog.brain_class = DummyOldBrain
foo = self.site.foo
missing = TheClass('missing').__of__(foo)
@@ -211,6 +219,7 @@
["reindex /site/foo ('allowedRolesAndUsers',)"])
self.failIf(foo.notified)
self.failIf(missing.notified)
+ self.assertEqual( len(self.logged), 1 ) # logging because no raise
# FIXME: more tests needed
=== Products/CMFCore/tests/test_DirectoryView.py 1.19.10.7 => 1.19.10.8 ===
--- Products/CMFCore/tests/test_DirectoryView.py:1.19.10.7 Fri Jul 8 09:24:32 2005
+++ Products/CMFCore/tests/test_DirectoryView.py Fri Jul 15 22:30:31 2005
@@ -15,9 +15,10 @@
from Products.CMFCore.tests.base.dummy import DummyFolder
from Products.CMFCore.tests.base.testcase import _prefix
from Products.CMFCore.tests.base.testcase import FSDVTest
+from Products.CMFCore.tests.base.testcase import WarningInterceptor
-class DirectoryViewPathTests( TestCase ):
+class DirectoryViewPathTests( TestCase, WarningInterceptor ):
"""
These test that, no matter what is stored in their dirpath,
FSDV's will do their best to find an appropriate skin
@@ -32,6 +33,9 @@
self.ob = DummyFolder()
addDirectoryViews(self.ob, 'fake_skins', _prefix)
+ def tearDown(self):
+ self._free_warning_output()
+
def test_getDirectoryInfo(self):
skin = self.ob.fake_skin
skin.manage_properties('CMFCore/tests/fake_skins/fake_skin')
@@ -98,6 +102,7 @@
# Test we do nothing if given a really wacky path
def test_UnhandleableExpandPath( self ):
from tempfile import mktemp
+ self._trap_warning_output()
file = mktemp()
self.ob.fake_skin.manage_properties(file)
self.assertEqual(self.ob.fake_skin.objectIds(),[])
@@ -107,6 +112,7 @@
text = 'DirectoryView fake_skin refers to a non-existing path %s' % file
text = text.replace('\\','/')
self.assert_(text in warnings)
+ self.failUnless(text in self._our_stderr_stream.getvalue())
def test_UnhandleableMinimalPath( self ):
from Products.CMFCore.utils import minimalpath, normalize
=== Products/CMFCore/tests/test_FSSecurity.py 1.7.14.4 => 1.7.14.5 ===
--- Products/CMFCore/tests/test_FSSecurity.py:1.7.14.4 Fri Jul 8 09:24:32 2005
+++ Products/CMFCore/tests/test_FSSecurity.py Fri Jul 15 22:30:31 2005
@@ -13,9 +13,10 @@
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import RequestTest
+from Products.CMFCore.tests.base.testcase import LogInterceptor
-class FSSecurityBase( RequestTest, FSDVTest ):
+class FSSecurityBase( RequestTest, FSDVTest, LogInterceptor ):
def _checkSettings(self, object, permissionname, acquire=0, roles=[]):
# check the roles and acquire settings for a permission on an
@@ -54,9 +55,10 @@
def tearDown( self ):
RequestTest.tearDown(self)
FSDVTest.tearDown(self)
+ self._ignore_log_errors()
-class FSSecurityTests( FSSecurityBase ):
+class FSSecurityTests( FSSecurityBase, LogInterceptor ):
def test_basicPermissions( self ):
# Test basic FS permissions
@@ -67,6 +69,8 @@
self._checkSettings(self.ob.fake_skin.test4,'Access contents information',0,[])
def test_invalidPermissionNames( self ):
+ import zLOG
+ self._catch_log_errors(zLOG.ERROR)
# Test for an invalid permission name
# baseline
self._checkSettings(self.ob.fake_skin.test5,'View',1,[])
=== Products/CMFCore/tests/test_TypesTool.py 1.32.2.7 => 1.32.2.8 ===
--- Products/CMFCore/tests/test_TypesTool.py:1.32.2.7 Fri Jul 8 09:24:32 2005
+++ Products/CMFCore/tests/test_TypesTool.py Fri Jul 15 22:30:31 2005
@@ -23,9 +23,6 @@
import Zope as Zope2
Zope2.startup()
-from warnings import filterwarnings
-from warnings import filters
-
from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
@@ -45,6 +42,7 @@
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.security import UserWithRoles
from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.testcase import WarningInterceptor
from Products.CMFCore.tests.base.tidata import FTIDATA_ACTIONS
from Products.CMFCore.tests.base.tidata import FTIDATA_CMF13
from Products.CMFCore.tests.base.tidata import FTIDATA_CMF13_FOLDER
@@ -58,7 +56,7 @@
from Products.CMFCore.utils import _getViewFor
-class TypesToolTests(SecurityTest):
+class TypesToolTests(SecurityTest, WarningInterceptor):
def _makeOne(self):
from Products.CMFCore.TypesTool import TypesTool
@@ -70,7 +68,6 @@
SecurityTest.setUp(self)
- filterwarnings('ignore', category=DeprecationWarning)
self.site = DummySite('site').__of__(self.root)
self.acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
self.ttool = self.site._setObject( 'portal_types', self._makeOne() )
@@ -78,9 +75,8 @@
self.ttool._setObject( 'Dummy Content', FTI(**fti) )
def tearDown(self):
- del filters[0]
-
SecurityTest.tearDown(self)
+ self._free_warning_output()
def test_z2interfaces(self):
from Interface.Verify import verifyClass
@@ -122,6 +118,7 @@
dummy.edit = DummyObject("edit")
default_view = dummy()
+ self._trap_warning_output()
custom_view = _getViewFor( dummy, view='view2' )()
unpermitted_view = _getViewFor( dummy, view='edit' )()
@@ -223,22 +220,22 @@
# Now try with the old representation, which will throw a BadRequest
# unless the workaround in the code is used
+ self._trap_warning_output()
ti_factory(ti_type, id='NewType2', typeinfo_name=old_repr)
self.failUnless('NewType2' in self.ttool.objectIds())
+ self.failUnless('DeprecationWarning' in
+ self._our_stderr_stream.getvalue())
-class TypeInfoTests(TestCase):
+class TypeInfoTests(TestCase, WarningInterceptor):
def _makeTypesTool(self):
from Products.CMFCore.TypesTool import TypesTool
return TypesTool()
- def setUp(self):
- filterwarnings('ignore', category=DeprecationWarning)
-
def tearDown(self):
- del filters[0]
+ self._free_warning_output()
def test_construction( self ):
ti = self._makeInstance( 'Foo'
@@ -336,6 +333,7 @@
self.failIf( 'slot' in visible )
def test_getActionById( self ):
+ self._trap_warning_output()
ti = self._makeInstance( 'Foo' )
marker = []
self.assertEqual( id( ti.getActionById( 'view', marker ) )
More information about the CMF-checkins
mailing list