Skip to content

Commit ce1eb1a

Browse files
Shawn Axsomthomasballinger
Shawn Axsom
authored andcommitted
Add tests
1 parent b286770 commit ce1eb1a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

bpython/autocomplete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def list_attributes(self, obj):
335335
return dir(obj)
336336

337337

338-
class ArrayObjectMembersCompletion(BaseCompletionType):
338+
class ArrayItemMembersCompletion(BaseCompletionType):
339339

340340
def __init__(self, shown_before_tab=True, mode=SIMPLE):
341341
self._shown_before_tab = shown_before_tab
@@ -603,7 +603,7 @@ def get_default_completer(mode=SIMPLE):
603603
MagicMethodCompletion(mode=mode),
604604
MultilineJediCompletion(mode=mode),
605605
GlobalCompletion(mode=mode),
606-
ArrayObjectMembersCompletion(mode=mode),
606+
ArrayItemMembersCompletion(mode=mode),
607607
CumulativeCompleter((AttrCompletion(mode=mode),
608608
ParameterNameCompletion(mode=mode)),
609609
mode=mode)

bpython/test/test_autocomplete.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,22 @@ def __getattr__(self, attr):
263263
self.com.matches(4, 'a.__', locals_=locals_))
264264

265265

266+
class TestArrayItemCompletion(unittest.TestCase):
267+
@classmethod
268+
def setUpClass(cls):
269+
cls.com = autocomplete.ArrayItemMembersCompletion()
270+
271+
def test_att_matches_found_on_instance(self):
272+
self.assertSetEqual(self.com.matches(5, 'a[0].', locals_={'a': [Foo()]}),
273+
set(['a[0].method', 'a[0].a', 'a[0].b']))
274+
275+
@skip_old_style
276+
def test_att_matches_found_on_old_style_instance(self):
277+
self.assertSetEqual(self.com.matches(5, 'a[0].',
278+
locals_={'a': [OldStyleFoo()]}),
279+
set(['a[0].method', 'a[0].a', 'a[0].b']))
280+
281+
266282
class TestMagicMethodCompletion(unittest.TestCase):
267283

268284
def test_magic_methods_complete_after_double_underscores(self):

0 commit comments

Comments
 (0)