[Zope-Checkins] CVS: Zope2 - testUnKeywordIndex.py:1.1.4.2

Jim Fulton jim@digicool.com
Tue, 20 Mar 2001 08:04:27 -0500 (EST)


Update of /cvs-repository/Zope2/lib/python/SearchIndex/tests
In directory korak:/tmp/cvs-serv6703

Modified Files:
      Tag: zope-2_3-branch
	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:10:34	1.1.4.1
+++ testUnKeywordIndex.py	2001/03/20 13:04:26	1.1.4.2
@@ -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()