[Zope-CVS] CVS: Packages/FunctionalTests/FunctionalTests -
Result.py:1.2.4.2
Karl Anderson
cvs-admin at zope.org
Thu Nov 13 16:12:30 EST 2003
Update of /cvs-repository/Packages/FunctionalTests/FunctionalTests
In directory cvs.zope.org:/tmp/cvs-serv409
Modified Files:
Tag: kra-intersest-branch
Result.py
Log Message:
Result: added checkHook(), callHook(), _check_hook args and attrs
Result.newChild(): pass init args that were missing (bugfix) and checkHook
Result._validateInvocation(): added force_check_hook arg, call hook if
appropriate
=== Packages/FunctionalTests/FunctionalTests/Result.py 1.2.4.1 => 1.2.4.2 ===
--- Packages/FunctionalTests/FunctionalTests/Result.py:1.2.4.1 Thu Nov 13 13:18:34 2003
+++ Packages/FunctionalTests/FunctionalTests/Result.py Thu Nov 13 16:12:30 2003
@@ -27,6 +27,7 @@
, check_redirects=1
, check_content=1
, check_elapsed_times=1
+ , check_hook=1
):
self._test = test
@@ -39,6 +40,7 @@
self._check_redirects = check_redirects
self._check_content = check_content
self._check_elapsed_times = check_elapsed_times and time_requests
+ self._check_hook = check_hook
self._invocations = []
self._errors = []
self._fatal_errors = []
@@ -149,7 +151,13 @@
""" See IResult.
"""
return self._check_elapsed_times
-
+
+ def checkHook( self ):
+
+ """ See IResult.
+ """
+ return self._check_hook
+
def listInvocations( self, roll_up=1 ):
""" See IResult.
@@ -216,7 +224,10 @@
, self._defaults #getDefaults() # hackish, globalize?
, self.timeRequests()
, self.checkResponses()
+ , self.checkRedirects()
+ , self.checkContent()
, self.checkElapsedTimes()
+ , self.checkHook()
)
child.setParent( self )
self._children.append( child )
@@ -247,6 +258,7 @@
, force_check_redirects=0
, force_check_content=0
, force_check_time=0
+ , force_check_hook=0
):
""" Test the result against the required conditions.
@@ -265,6 +277,10 @@
if self.checkElapsedTimes() or force_check_time:
self._validateElapsedTime( invocation, request )
+ # the hook is not really a test, but we want to validate that it
+ # was called properly
+ if self.checkHook() or force_check_hook:
+ self._callHook( invocation, request )
def _validateResponse( self, invocation, request ):
@@ -322,3 +338,20 @@
msg = '[%-10s] elapsed: %s != %s' % ( request.getName()
, got, expected )
self.logError( msg )
+
+ def _callHook( self, invocation, request ):
+
+ """ Apply post-invocation hook.
+
+ o Log problems to self._fatal_errors / self._errors
+ """
+ hook = request.getHook()
+
+ if hook is not None:
+ try:
+ # XXX again passing _defaults
+ hook( request, invocation, self._defaults )
+ except Exception, error:
+ msg = '[%-10s] : hook error: %s' % ( request.getName()
+ , error )
+ self.logError( msg )
More information about the Zope-CVS
mailing list