Statistics
| Revision:

gvsig-scripting / org.gvsig.scripting.app / trunk / org.gvsig.scripting.app / org.gvsig.scripting.app.extension / src / main / resources / scripting / lib / console / testcase.py @ 359

History | View | Annotate | Download (995 Bytes)

1
import unittest
2
import introspect
3

    
4
class IntrospectTestCase(unittest.TestCase):
5

    
6
    def testUnboundMethod(self):
7
        import string
8
        method = 'string.index('
9
        (name, argspec, tip) = introspect.getCallTip(method, locals())
10

    
11
        self.assertEquals('index', name)
12
        self.assertEquals('s, *args', argspec)
13
        self.assertEquals('index(s, *args)\n\nindex(s, sub [,start [,end]]) -> int\n\nLike find but raises ValueError when the substring is not found.', tip)
14

    
15
    def testBuiltinFunction(self):
16
        method = 'len('
17
        print introspect.getCallTip(method, locals())
18
        
19
        (name, argspec, tip) = introspect.getCallTip(method, locals())
20
        
21
        self.assertEquals('len', name)
22
        # next 2 assertions fail in Jython!
23
        self.assertEquals('len(object) -> integer', argspec)
24
        self.assertEquals('len(object) -> integer\n\nReturn the number of items of a sequence or mapping', tip)
25

    
26

    
27
if __name__ == '__main__':
28
    unittest.main()