##// END OF EJS Templates
First step in reintegrating Jedi...
First step in reintegrating Jedi If Jedi is installed expose a private API use it with prompt toolkit. Jedi does not _yet_ provide all the completion IPython has, so this is still a bit awkward. In order to debug this (and see what is Jedi provided we for now inject a fake Jedi/IPython delimiter in the menu. Jedi completion and this behavior are enabled by default, but could likely be opt-in. Add also a number of debug flags to be able to track why jedi is not working, and/or what completions are found by IPython and not Jedi. That should give us a bit of heads up and feedback to know whether we can remove part of the IPython completer, and more especially if we can drop `python_matches`. Once `python_matches` is dropped and some other of the current matchers are either dropped or converted to the new API, that should simplify the internal quite a bit. That would just be too much for an already BIG pull-request.

File last commit:

r13392:bace1f46
r23284:3ff1be2e
Show More
test_wildcard.py
143 lines | 4.6 KiB | text/x-python | PythonLexer
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 """Some tests for the wildcard utilities."""
vivainio
merge all from 0.7.3 branch to trunk
r503
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 #-----------------------------------------------------------------------------
# Library imports
#-----------------------------------------------------------------------------
# Stdlib
import unittest
# Our own
from IPython.utils import wildcard
#-----------------------------------------------------------------------------
# Globals for test
#-----------------------------------------------------------------------------
vivainio
merge all from 0.7.3 branch to trunk
r503
class obj_t(object):
pass
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 root = obj_t()
l = ["arna","abel","ABEL","active","bob","bark","abbot"]
q = ["kate","loop","arne","vito","lucifer","koppel"]
vivainio
merge all from 0.7.3 branch to trunk
r503 for x in l:
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 o = obj_t()
vivainio
merge all from 0.7.3 branch to trunk
r503 setattr(root,x,o)
for y in q:
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 p = obj_t()
vivainio
merge all from 0.7.3 branch to trunk
r503 setattr(o,y,p)
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 root._apan = obj_t()
root._apan.a = 10
root._apan._a = 20
root._apan.__a = 20
root.__anka = obj_t()
root.__anka.a = 10
root.__anka._a = 20
root.__anka.__a = 20
root._APAN = obj_t()
root._APAN.a = 10
root._APAN._a = 20
root._APAN.__a = 20
root.__ANKA = obj_t()
root.__ANKA.a = 10
root.__ANKA._a = 20
root.__ANKA.__a = 20
vivainio
merge all from 0.7.3 branch to trunk
r503
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 #-----------------------------------------------------------------------------
# Test cases
#-----------------------------------------------------------------------------
vivainio
merge all from 0.7.3 branch to trunk
r503
class Tests (unittest.TestCase):
def test_case(self):
ns=root.__dict__
tests=[
("a*", ["abbot","abel","active","arna",]),
("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",]),
("_a*", []),
("_*anka", ["__anka",]),
("_*a*", ["__anka",]),
]
for pat,res in tests:
res.sort()
Thomas Kluyver
Fix tests in IPython.utils
r13392 a=sorted(wildcard.list_namespace(ns,"all",pat,ignore_case=False,
show_all=False).keys())
vivainio
merge all from 0.7.3 branch to trunk
r503 self.assertEqual(a,res)
def test_case_showall(self):
ns=root.__dict__
tests=[
("a*", ["abbot","abel","active","arna",]),
("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",]),
("_a*", ["_apan"]),
("_*anka", ["__anka",]),
("_*a*", ["__anka","_apan",]),
]
for pat,res in tests:
res.sort()
Thomas Kluyver
Fix tests in IPython.utils
r13392 a=sorted(wildcard.list_namespace(ns,"all",pat,ignore_case=False,
show_all=True).keys())
vivainio
merge all from 0.7.3 branch to trunk
r503 self.assertEqual(a,res)
def test_nocase(self):
ns=root.__dict__
tests=[
("a*", ["abbot","abel","ABEL","active","arna",]),
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",
"ABEL.koppel","ABEL.loop",]),
vivainio
merge all from 0.7.3 branch to trunk
r503 ("_a*", []),
("_*anka", ["__anka","__ANKA",]),
("_*a*", ["__anka","__ANKA",]),
]
for pat,res in tests:
res.sort()
Thomas Kluyver
Fix tests in IPython.utils
r13392 a=sorted(wildcard.list_namespace(ns,"all",pat,ignore_case=True,
show_all=False).keys())
vivainio
merge all from 0.7.3 branch to trunk
r503 self.assertEqual(a,res)
def test_nocase_showall(self):
ns=root.__dict__
tests=[
("a*", ["abbot","abel","ABEL","active","arna",]),
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",
"ABEL.koppel","ABEL.loop",]),
vivainio
merge all from 0.7.3 branch to trunk
r503 ("_a*", ["_apan","_APAN"]),
("_*anka", ["__anka","__ANKA",]),
("_*a*", ["__anka","__ANKA","_apan","_APAN"]),
]
for pat,res in tests:
res.sort()
Thomas Kluyver
Fix tests in IPython.utils
r13392 a=sorted(wildcard.list_namespace(ns,"all",pat,ignore_case=True,
show_all=True).keys())
vivainio
merge all from 0.7.3 branch to trunk
r503 a.sort()
self.assertEqual(a,res)
Thomas Kluyver
Test for the problem underlying issue 129.
r3261
def test_dict_attributes(self):
"""Dictionaries should be indexed by attributes, not by keys. This was
causing Github issue 129."""
ns = {"az":{"king":55}, "pq":{1:0}}
tests = [
("a*", ["az"]),
("az.k*", ["az.keys"]),
("pq.k*", ["pq.keys"])
]
for pat, res in tests:
res.sort()
Thomas Kluyver
Fix tests in IPython.utils
r13392 a = sorted(wildcard.list_namespace(ns, "all", pat, ignore_case=False,
show_all=True).keys())
Thomas Kluyver
Test for the problem underlying issue 129.
r3261 self.assertEqual(a, res)
Thomas Kluyver
Add test for dict_dir method in utils.wildcard
r3357
def test_dict_dir(self):
class A(object):
def __init__(self):
self.a = 1
self.b = 2
def __getattribute__(self, name):
if name=="a":
raise AttributeError
return object.__getattribute__(self, name)
a = A()
adict = wildcard.dict_dir(a)
assert "a" not in adict # change to assertNotIn method in >= 2.7
self.assertEqual(adict["b"], 2)