Debian Codegraph @

test/jpypetest/test_jedi.py

raw symbols SCIP
1 # *****************************************************************************
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 # See NOTICE file for details.
16 #
17 # *****************************************************************************
18 import sys
19 import jpype
20 import common
21 import types
22 import functools
23 import inspect
24
25
26 have_jedi = False
27 try:
28 import jedi
29 have_jedi = (common.version(jedi.__version__) > (0, 14))
30 except:
31 pass
32
33 # FIXME: some jedi version is causing an issue jpype-project/jpype#920 so we pretend not to have jedi, until it is resolved.
34 have_jedi = False
35
36 class JediTestCase(common.JPypeTestCase):
37 """Test tab completion on JPype objects
38 """
39
40 def setUp(self):
41 common.JPypeTestCase.setUp(self)
42 if common.fast:
43 raise common.unittest.SkipTest("fast")
44 self.cls = jpype.JClass('java.lang.String')
45 self.obj = self.cls('foo')
46
47 @common.unittest.skipUnless(have_jedi, "jedi not available")
48 def testCompleteClass(self):
49 src = 'self.obj.con'
50 script = jedi.Interpreter(src, [locals()])
51 compl = [i.name for i in script.complete()]
52 self.assertEqual(compl, ['concat', 'contains', 'contentEquals'])
53
54 @common.unittest.skipUnless(have_jedi, "jedi not available")
55 def testCompleteMethod(self):
56 src = 'self.obj.substring(1).con'
57 script = jedi.Interpreter(src, [locals()])
58 compl = [i.name for i in script.complete()]
59 self.assertEqual(compl, ['concat', 'contains', 'contentEquals'])
60
61 @common.unittest.skipUnless(have_jedi, "jedi not available")
62 def testCompleteField(self):
63 src = 'self.obj.CASE_INSENSITIVE_ORDER.wa'
64 script = jedi.Interpreter(src, [locals()])
65 compl = [i.name for i in script.complete()]
66 self.assertEqual(compl, ['wait'])
67
68 @common.unittest.skipUnless(have_jedi, "jedi not available")
69 def testCompleteMethodField(self):
70 src = 'self.obj.substring(1).CAS'
71 script = jedi.Interpreter(src, [locals()])
72 compl = [i.name for i in script.complete()]
73 self.assertEqual(compl, ['CASE_INSENSITIVE_ORDER'])