[Zope-Checkins] CVS: Zope2 - testUnKeywordIndex.py:1.3
Jim Fulton
jim@digicool.com
Tue, 20 Mar 2001 08:49:36 -0500 (EST)
Update of /cvs-repository/Zope2/lib/python/SearchIndex/tests
In directory korak:/tmp/cvs-serv9612
Modified Files:
testUnKeywordIndex.py
Log Message:
Fixed checks to work with TreeSets, now that TreeSets have length but
are (still) not sequences.
Added standard main test functions and function-choosing script
handler.
--- Updated File testUnKeywordIndex.py in package Zope2 --
--- testUnKeywordIndex.py 2001/03/15 13:16:25 1.2
+++ testUnKeywordIndex.py 2001/03/20 13:49:36 1.3
@@ -143,14 +143,11 @@
def _checkApply( self, req, expectedValues ):
result, used = self._index._apply_index( req )
assert used == ( 'foo', )
- try:
- length = len(result)
- except:
- result = result.keys()
- length = len(result)
- assert length == len( expectedValues ), \
+ assert len(result) == len( expectedValues ), \
'%s | %s' % ( map( None, result ),
map(lambda x: x[0], expectedValues ))
+
+ if hasattr(result, 'keys'): result=result.keys()
for k, v in expectedValues:
assert k in result
@@ -208,7 +205,19 @@
def test_suite():
return unittest.makeSuite( TestCase )
+def main():
+ unittest.TextTestRunner().run( test_suite() )
+
+def debug():
+ test_suite().debug()
+def pdebug():
+ import pdb
+ pdb.run('debug()')
+
if __name__ == '__main__':
- unittest.TextTestRunner().run( test_suite() )
+ if len(sys.argv) > 1:
+ globals()[sys.argv[1]]()
+ else:
+ main()