##// END OF EJS Templates
ipy_leo: rename wb..val => wb..v, %leo now opens a file in leo
ipy_leo: rename wb..val => wb..v, %leo now opens a file in leo

File last commit:

r987:9c4e4577
r989:f2d27822
Show More
test_ipapi.py
54 lines | 1.0 KiB | text/x-python | PythonLexer
vivainio
callable aliases now get _ip as first arg
r833 import sys
sys.path.append('..')
vivainio
add test cases for ipapi
r774 import IPython.ipapi
IPython.ipapi.make_session()
ip = IPython.ipapi.get()
def test_runlines():
vivainio
_ip.runlines() is now much more liberal about indentation - it cleans up the scripts it gets
r987 import textwrap
vivainio
add test cases for ipapi
r774 ip.runlines(['a = 10', 'a+=1'])
vivainio
_ip.runlines() is now much more liberal about indentation - it cleans up the scripts it gets
r987 ip.runlines('assert a == 11\nassert 1')
vivainio
add test cases for ipapi
r774 assert ip.user_ns['a'] == 11
vivainio
_ip.runlines() is now much more liberal about indentation - it cleans up the scripts it gets
r987 complex = textwrap.dedent("""\
if 1:
print "hello"
if 1:
print "world"
if 1:
print "foo"
if 1:
print "bar"
if 1:
print "bar"
""")
ip.runlines(complex)
vivainio
add test cases for ipapi
r774
def test_db():
ip.db['__unittest_'] = 12
assert ip.db['__unittest_'] == 12
del ip.db['__unittest_']
assert '__unittest_' not in ip.db
def test_defalias():
slot = [None]
# test callable alias
vivainio
callable aliases now get _ip as first arg
r833 def cb(localip,s):
assert localip is ip
vivainio
add test cases for ipapi
r774 slot[0] = s
ip.defalias('testalias', cb)
ip.runlines('testalias foo bar')
assert slot[0] == 'testalias foo bar'
test_runlines()
test_db()
test_defalias