summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_rlcompleter.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-11-24 00:19:10 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-11-24 00:19:10 (GMT)
commit450c9881849d5489ff21d77648f2231d0176c0a5 (patch)
tree7e69a3238d52b657f16761e8c754ec17e9bc479f /Lib/test/test_rlcompleter.py
parentf50fe724de181947f73fd6fd1f54bda5415590c9 (diff)
parent11bb1ad15502849f126af3f35de7eaeebd617fc5 (diff)
downloadcpython-450c9881849d5489ff21d77648f2231d0176c0a5.zip
cpython-450c9881849d5489ff21d77648f2231d0176c0a5.tar.gz
cpython-450c9881849d5489ff21d77648f2231d0176c0a5.tar.bz2
Issue #25663: Merge rlcompleter fix from 3.5
Diffstat (limited to 'Lib/test/test_rlcompleter.py')
-rw-r--r--Lib/test/test_rlcompleter.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
index 8ff75c7..34a5eff 100644
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -113,5 +113,26 @@ class TestRlcompleter(unittest.TestCase):
self.assertEqual(completer.complete('el', 1), 'else')
self.assertEqual(completer.complete('tr', 0), 'try:')
+ def test_duplicate_globals(self):
+ namespace = {
+ 'False': None, # Keyword vs builtin vs namespace
+ 'assert': None, # Keyword vs namespace
+ 'try': lambda: None, # Keyword vs callable
+ 'memoryview': None, # Callable builtin vs non-callable
+ 'Ellipsis': lambda: None, # Non-callable builtin vs callable
+ }
+ completer = rlcompleter.Completer(namespace)
+ self.assertEqual(completer.complete('False', 0), 'False')
+ self.assertIsNone(completer.complete('False', 1)) # No duplicates
+ self.assertEqual(completer.complete('assert', 0), 'assert')
+ self.assertIsNone(completer.complete('assert', 1))
+ self.assertEqual(completer.complete('try', 0), 'try')
+ self.assertIsNone(completer.complete('try', 1))
+ # No opening bracket "(" because we overrode the built-in class
+ self.assertEqual(completer.complete('memoryview', 0), 'memoryview')
+ self.assertIsNone(completer.complete('memoryview', 1))
+ self.assertEqual(completer.complete('Ellipsis', 0), 'Ellipsis(')
+ self.assertIsNone(completer.complete('Ellipsis', 1))
+
if __name__ == '__main__':
unittest.main()