[Zope-Checkins] CVS: Zope3/lib/python/Zope/Testing - Builder.py:1.1.4.2
Tres Seaver
tseaver@zope.com
Wed, 21 Nov 2001 17:03:04 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Testing
In directory cvs.zope.org:/tmp/cvs-serv1804/lib/python/Zope/Testing
Modified Files:
Tag: Zope-3x-branch
Builder.py
Log Message:
- Unit testing cleanups.
=== Zope3/lib/python/Zope/Testing/Builder.py 1.1.4.1 => 1.1.4.2 ===
self._candidates.append( '.'.join( elements ) )
+ def _recordLoadFailure( 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, '')
+ self._cant_load.append( ( header, body ) )
+
def _buildSuite( self ):
"""
Build a suite from our candidate modules.
"""
suite = unittest.TestSuite()
self._cant_load = []
- loaded = []
+ self._loaded = []
+
for candidate in self._candidates:
+
try:
suite.addTest( self.loadTestsFromName( '%s.test_suite'
% candidate ) )
- loaded.append( '%s (test_suite)' % candidate )
- except ValueError:
- try:
- suite.addTest( self.loadTestsFromName( candidate ) )
- append( '%s (implicit)' % candidate )
- except ValueError, msg:
- self._cant_load.append( '[%s] %s' % ( candidate, msg ) )
+ self._loaded.append( '%s (test_suite)' % candidate )
+ continue
+ except:
+ pass
+
+ try:
+ suite.addTest( self.loadTestsFromName( candidate ) )
+ self._loaded.append( '%s (implicit)' % candidate )
except Exception, msg:
- self._cant_load.append( '[%s] %s' % ( candidate, msg ) )
- return suite, loaded
+ self._recordLoadFailure( candidate, msg )
+ return suite
def loadTestsFromPath( self, path=None ):
self._candidates = []
- self._cant_load = []
if path is None:
path = self._sw_home
os.path.walk( path, self._visit, None )
- suite, loaded = self._buildSuite()
+ suite = self._buildSuite()
+ suite.warnings = self._cant_load
+ suite.loaded = self._loaded
return suite
@@ -201,4 +214,5 @@
def allZopeTests():
#suite, failed_imports = extractSuite( sw_home )
#return suite
- return TestFinder().loadTestsFromPath()
+ import Zope
+ return TestFinder().loadTestsFromPath( Zope.__path__[0] )