Commit 3451d7f6 authored by Jim Fulton's avatar Jim Fulton

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.
parent 29b846f7
...@@ -143,14 +143,11 @@ class TestCase( unittest.TestCase ): ...@@ -143,14 +143,11 @@ class TestCase( unittest.TestCase ):
def _checkApply( self, req, expectedValues ): def _checkApply( self, req, expectedValues ):
result, used = self._index._apply_index( req ) result, used = self._index._apply_index( req )
assert used == ( 'foo', ) assert used == ( 'foo', )
try: assert len(result) == len( expectedValues ), \
length = len(result)
except:
result = result.keys()
length = len(result)
assert length == len( expectedValues ), \
'%s | %s' % ( map( None, result ), '%s | %s' % ( map( None, result ),
map(lambda x: x[0], expectedValues )) map(lambda x: x[0], expectedValues ))
if hasattr(result, 'keys'): result=result.keys()
for k, v in expectedValues: for k, v in expectedValues:
assert k in result assert k in result
...@@ -208,7 +205,19 @@ class TestCase( unittest.TestCase ): ...@@ -208,7 +205,19 @@ class TestCase( unittest.TestCase ):
def test_suite(): def test_suite():
return unittest.makeSuite( TestCase ) 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__': if __name__ == '__main__':
unittest.TextTestRunner().run( test_suite() ) if len(sys.argv) > 1:
globals()[sys.argv[1]]()
else:
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment