[CMF-checkins] CVS: Products/CMFCore/tests -
test_CMFCatalogAware.py:1.7 test_DirectoryView.py:1.28
test_FSSecurity.py:1.11 test_TypesTool.py:1.40
Tres Seaver
tseaver at palladion.com
Fri Jul 15 22:31:33 EDT 2005
Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv15502/CMFCore/tests
Modified Files:
test_CMFCatalogAware.py test_DirectoryView.py
test_FSSecurity.py test_TypesTool.py
Log Message:
- Forward-ported testing framework to suppress / examine output from
warnings module and from zLOG from 1.5 branch.
=== Products/CMFCore/tests/test_CMFCatalogAware.py 1.6 => 1.7 ===
--- Products/CMFCore/tests/test_CMFCatalogAware.py:1.6 Wed Jun 15 10:59:10 2005
+++ Products/CMFCore/tests/test_CMFCatalogAware.py Fri Jul 15 22:31:02 2005
@@ -26,6 +26,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):
@@ -96,7 +97,7 @@
self.notified = True
-class CMFCatalogAwareTests(unittest.TestCase):
+class CMFCatalogAwareTests(unittest.TestCase, LogInterceptor):
def setUp(self):
self.root = DummyRoot('')
@@ -105,6 +106,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
@@ -153,15 +157,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
@@ -172,6 +179,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.27 => 1.28 ===
--- Products/CMFCore/tests/test_DirectoryView.py:1.27 Wed Jun 15 10:17:38 2005
+++ Products/CMFCore/tests/test_DirectoryView.py Fri Jul 15 22:31:02 2005
@@ -12,6 +12,7 @@
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
from Products.CMFCore.DirectoryView import DirectoryView
@@ -24,7 +25,7 @@
pass
-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
@@ -39,6 +40,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')
@@ -105,6 +109,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(),[])
@@ -114,6 +119,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.10 => 1.11 ===
--- Products/CMFCore/tests/test_FSSecurity.py:1.10 Wed Jun 15 10:17:38 2005
+++ Products/CMFCore/tests/test_FSSecurity.py Fri Jul 15 22:31:02 2005
@@ -26,9 +26,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
@@ -67,9 +68,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
@@ -80,6 +82,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.39 => 1.40 ===
--- Products/CMFCore/tests/test_TypesTool.py:1.39 Wed Jun 15 10:17:38 2005
+++ Products/CMFCore/tests/test_TypesTool.py Fri Jul 15 22:31:02 2005
@@ -39,6 +39,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
@@ -51,7 +52,7 @@
from Products.CMFCore.tests.base.tidata import STI_SCRIPT
-class TypesToolTests(SecurityTest):
+class TypesToolTests(SecurityTest, WarningInterceptor):
def _makeOne(self):
from Products.CMFCore.TypesTool import TypesTool
@@ -69,6 +70,10 @@
fti = FTIDATA_DUMMY[0].copy()
self.ttool._setObject( 'Dummy Content', FTI(**fti) )
+ def tearDown(self):
+ SecurityTest.tearDown(self)
+ self._free_warning_output()
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
@@ -182,8 +187,11 @@
# 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):
More information about the CMF-checkins
mailing list