| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
|
| 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']) |