mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #25590: Merge rlcompleter getattr change from 3.5
This commit is contained in:
commit
f4ad5f5dea
3 changed files with 21 additions and 3 deletions
|
@ -79,6 +79,19 @@ class TestRlcompleter(unittest.TestCase):
|
|||
['egg.{}('.format(x) for x in dir(str)
|
||||
if x.startswith('s')])
|
||||
|
||||
def test_excessive_getattr(self):
|
||||
# Ensure getattr() is invoked no more than once per attribute
|
||||
class Foo:
|
||||
calls = 0
|
||||
@property
|
||||
def bar(self):
|
||||
self.calls += 1
|
||||
return None
|
||||
f = Foo()
|
||||
completer = rlcompleter.Completer(dict(f=f))
|
||||
self.assertEqual(completer.complete('f.b', 0), 'f.bar')
|
||||
self.assertEqual(f.calls, 1)
|
||||
|
||||
def test_complete(self):
|
||||
completer = rlcompleter.Completer()
|
||||
self.assertEqual(completer.complete('', 0), '\t')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue