[CMF-checkins] CVS: Products/CMFCore/tests/base -
testcase.py:1.10.10.4
Tres Seaver
tseaver at palladion.com
Fri Jul 15 22:30:32 EDT 2005
Update of /cvs-repository/Products/CMFCore/tests/base
In directory cvs.zope.org:/tmp/cvs-serv15086/CMFCore/tests/base
Modified Files:
Tag: CMF-1_5-branch
testcase.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/base/testcase.py 1.10.10.3 => 1.10.10.4 ===
--- Products/CMFCore/tests/base/testcase.py:1.10.10.3 Wed Apr 6 05:53:39 2005
+++ Products/CMFCore/tests/base/testcase.py Fri Jul 15 22:30:32 2005
@@ -17,6 +17,7 @@
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from Testing.makerequest import makerequest
+import zLOG
try:
import transaction
except ImportError:
@@ -26,6 +27,58 @@
from dummy import DummyFolder
from security import AnonymousUser
from security import PermissiveSecurityPolicy
+
+class LogInterceptor:
+
+ _old_log_write = None
+ logged = None
+
+ def _catch_log_errors( self, ignored_level=zLOG.PROBLEM ):
+
+ if self._old_log_write is not None:
+ return
+
+ def log_write(subsystem, severity, summary, detail, error):
+ if severity > ignored_level:
+ assert 0, "%s(%s): %s" % (subsystem, severity, summary)
+ if self.logged is None:
+ self.logged = []
+ self.logged.append( ( subsystem, severity, summary, detail ) )
+
+ self._old_log_write = zLOG.log_write
+ zLOG.log_write = log_write
+
+ def _ignore_log_errors( self ):
+
+ if self._old_log_write is None:
+ return
+
+ zLOG.log_write = self._old_log_write
+ del self._old_log_write
+
+class WarningInterceptor:
+
+ _old_stderr = None
+ _our_stderr_stream = None
+
+ def _trap_warning_output( self ):
+
+ if self._old_stderr is not None:
+ return
+
+ import sys
+ from StringIO import StringIO
+
+ self._old_stderr = sys.stderr
+ self._our_stderr_stream = sys.stderr = StringIO()
+
+ def _free_warning_output( self ):
+
+ if self._old_stderr is None:
+ return
+
+ import sys
+ sys.stderr = self._old_stderr
class TransactionalTest( TestCase ):
More information about the CMF-checkins
mailing list