FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix magic method completion · bpython/bpython@e88bb1e · GitHub

Commit e88bb1e

Browse files
Fix magic method completion
MAGIC_METHODS constant had been a single-use generator
1 parent 70ec8e9 commit e88bb1e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎bpython/autocomplete.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
ALL_MODES = (SIMPLE, SUBSTRING, FUZZY)
4545

46-
MAGIC_METHODS = ("__%s__" % s for s in (
46+
MAGIC_METHODS = tuple("__%s__" % s for s in (
4747
"init", "repr", "str", "lt", "le", "eq", "ne", "gt", "ge", "cmp", "hash",
4848
"nonzero", "unicode", "getattr", "setattr", "get", "set", "call", "len",
4949
"getitem", "setitem", "iter", "reversed", "contains", "add", "sub", "mul",

‎bpython/test/test_autocomplete.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,12 @@ class TestAttrCompletion(unittest.TestCase):
187187
def test_att_matches_found_on_instance(self):
188188
com = autocomplete.AttrCompletion()
189189
self.assertSetEqual(com.matches(2, 'a.', {'a': Foo()}), set(['a.method', 'a.a', 'a.b']))
190+
191+
class TestMagicMethodCompletion(unittest.TestCase):
192+
193+
def test_magic_methods_complete_after_double_underscores(self):
194+
com = autocomplete.MagicMethodCompletion()
195+
block = "class Something(object)\n def __"
196+
self.assertSetEqual(com.matches(10, ' def __', block), set(autocomplete.MAGIC_METHODS))
197+
198+

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL