##// END OF EJS Templates
Continue refactoring input handling across clients....
Continue refactoring input handling across clients. Fixed a number of small but tricky bugs related to prompt numbering, now in all cases I can see both terminal and gui client are fully consistent regarding prompts.

File last commit:

r2657:f5f4be49
r3085:048fef29
Show More
test_wildcard.py
117 lines | 3.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 sys
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()
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,
show_all=False).keys()
vivainio
merge all from 0.7.3 branch to trunk
r503 a.sort()
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()
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,
show_all=True).keys()
vivainio
merge all from 0.7.3 branch to trunk
r503 a.sort()
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()
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,
show_all=False).keys()
vivainio
merge all from 0.7.3 branch to trunk
r503 a.sort()
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()
Fernando Perez
Moved old wildcard tests into proper test suite.
r2657 a=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)