Show More
@@ -0,0 +1,30 b'' | |||
|
1 | import IPython.ipapi | |
|
2 | ||
|
3 | IPython.ipapi.make_session() | |
|
4 | ip = IPython.ipapi.get() | |
|
5 | ||
|
6 | def test_runlines(): | |
|
7 | ip.runlines(['a = 10', 'a+=1']) | |
|
8 | ip.runlines('assert a == 11') | |
|
9 | assert ip.user_ns['a'] == 11 | |
|
10 | ||
|
11 | def test_db(): | |
|
12 | ip.db['__unittest_'] = 12 | |
|
13 | assert ip.db['__unittest_'] == 12 | |
|
14 | del ip.db['__unittest_'] | |
|
15 | assert '__unittest_' not in ip.db | |
|
16 | ||
|
17 | def test_defalias(): | |
|
18 | slot = [None] | |
|
19 | # test callable alias | |
|
20 | def cb(s): | |
|
21 | slot[0] = s | |
|
22 | ||
|
23 | ip.defalias('testalias', cb) | |
|
24 | ip.runlines('testalias foo bar') | |
|
25 | assert slot[0] == 'testalias foo bar' | |
|
26 | ||
|
27 | ||
|
28 | test_runlines() | |
|
29 | test_db() | |
|
30 | test_defalias |
General Comments 0
You need to be logged in to leave comments.
Login now