[Zope-Checkins] CVS: Zope3/lib/python/Zope/Testing - Builder.py:1.1.4.4
Chris McDonough
chrism@zope.com
Sat, 1 Dec 2001 17:16:25 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Testing
In directory cvs.zope.org:/tmp/cvs-serv24534
Modified Files:
Tag: Zope-3x-branch
Builder.py
Log Message:
Lamely show tests which fail to import by sending tracebacks to stdout.
=== Zope3/lib/python/Zope/Testing/Builder.py 1.1.4.3 => 1.1.4.4 ===
self._candiates = []
self._cant_load = []
+ self._maybe_cant_load = {}
def _guessSoftwareHome( self ):
"""
@@ -76,15 +77,23 @@
elements.append( basename )
self._candidates.append( '.'.join( elements ) )
- def _recordLoadFailure( self, candidate, msg ):
+ def _formatException( self, candidate, msg ):
"""
Grab the traceback and store, along with header info.
"""
header = '[%s] %s' % ( candidate, msg )
errLines = apply( traceback.format_exception, sys.exc_info() )
body = string.join( errLines, '')
+ return header, body
+
+ def _recordLoadFailure( self, candidate, msg ):
+ header, body = self._formatException(candidate, msg)
self._cant_load.append( ( header, body ) )
+ def _deferLoadFailure( self, candidate, msg ):
+ header, body = self._formatException(candidate, msg)
+ self._maybe_cant_load[candidate] = (header, body)
+
def _buildSuite( self ):
"""
Build a suite from our candidate modules.
@@ -100,14 +109,16 @@
% candidate ) )
self._loaded.append( '%s (test_suite)' % candidate )
continue
- except:
- pass
+ except Exception, msg:
+ self._deferLoadFailure(candidate, msg)
try:
suite.addTest( self.loadTestsFromName( candidate ) )
self._loaded.append( '%s (implicit)' % candidate )
except Exception, msg:
- self._recordLoadFailure( candidate, msg )
+ if self._maybe_cant_load.get(candidate):
+ self._cant_load.append(self._maybe_cant_load[candidate])
+ self._recordLoadFailure( '%s (implicit)' % candidate, msg )
return suite
def _loadTestsFromPath( self, path=None ):
@@ -118,6 +129,12 @@
suite = self._buildSuite()
suite.warnings = self._cant_load
suite.loaded = self._loaded
+ if suite.warnings:
+ print "There were failures loading tests"
+ print
+ for item in suite.warnings:
+ print item
+ print
return suite
__call__ = _loadTestsFromPath