##// END OF EJS Templates
Fix some tests using magics....
Fernando Perez -
Show More
@@ -207,6 +207,15 b' def start_ipython():'
207 _ip.IP.magic_run_ori = _ip.IP.magic_run
207 _ip.IP.magic_run_ori = _ip.IP.magic_run
208 _ip.IP.magic_run = im
208 _ip.IP.magic_run = im
209
209
210 # XXX - For some very bizarre reason, the loading of %history by default is
211 # failing. This needs to be fixed later, but for now at least this ensures
212 # that tests that use %hist run to completion.
213 from IPython import history
214 history.init_ipython(_ip)
215 if not hasattr(_ip.IP,'magic_history'):
216 raise RuntimeError("Can't load magics, aborting")
217
218
210 # The start call MUST be made here. I'm not sure yet why it doesn't work if
219 # The start call MUST be made here. I'm not sure yet why it doesn't work if
211 # it is made later, at plugin initialization time, but in all my tests, that's
220 # it is made later, at plugin initialization time, but in all my tests, that's
212 # the case.
221 # the case.
@@ -25,16 +25,23 b' def test_rehashx():'
25 _ip.magic('rehashx')
25 _ip.magic('rehashx')
26 # Practically ALL ipython development systems will have more than 10 aliases
26 # Practically ALL ipython development systems will have more than 10 aliases
27
27
28 assert len(_ip.IP.alias_table) > 10
28 yield (nt.assert_true, len(_ip.IP.alias_table) > 10)
29 for key, val in _ip.IP.alias_table.items():
29 for key, val in _ip.IP.alias_table.items():
30 # we must strip dots from alias names
30 # we must strip dots from alias names
31 assert '.' not in key
31 nt.assert_true('.' not in key)
32
32
33 # rehashx must fill up syscmdlist
33 # rehashx must fill up syscmdlist
34 scoms = _ip.db['syscmdlist']
34 scoms = _ip.db['syscmdlist']
35 assert len(scoms) > 10
35 yield (nt.assert_true, len(scoms) > 10)
36
36
37
37
38 ## def doctest_lsmagic():
39 ## """
40 ## In [15]: %lsmagic
41 ## Available magic functions:
42 ## %Exit
43 ## """
44
38 def doctest_hist_f():
45 def doctest_hist_f():
39 """Test %hist -f with temporary filename.
46 """Test %hist -f with temporary filename.
40
47
@@ -42,7 +49,8 b' def doctest_hist_f():'
42
49
43 In [10]: tfile = tempfile.mktemp('.py','tmp-ipython-')
50 In [10]: tfile = tempfile.mktemp('.py','tmp-ipython-')
44
51
45 In [11]: %history -n -f $tfile 3
52 In [11]: %hist -n -f $tfile 3
53
46 """
54 """
47
55
48
56
@@ -51,9 +59,12 b' def doctest_hist_r():'
51
59
52 XXX - This test is not recording the output correctly. Not sure why...
60 XXX - This test is not recording the output correctly. Not sure why...
53
61
62 In [20]: 'hist' in _ip.IP.lsmagic()
63 Out[20]: True
64
54 In [6]: x=1
65 In [6]: x=1
55
66
56 In [7]: hist -n -r 2
67 In [7]: %hist -n -r 2
57 x=1 # random
68 x=1 # random
58 hist -n -r 2 # random
69 hist -n -r 2 # random
59 """
70 """
@@ -94,12 +105,13 b' def test_shist():'
94
105
95 @dec.skipif_not_numpy
106 @dec.skipif_not_numpy
96 def test_numpy_clear_array_undec():
107 def test_numpy_clear_array_undec():
108 from IPython.Extensions import clearcmd
109
97 _ip.ex('import numpy as np')
110 _ip.ex('import numpy as np')
98 _ip.ex('a = np.empty(2)')
111 _ip.ex('a = np.empty(2)')
99
112 yield (nt.assert_true, 'a' in _ip.user_ns)
100 yield nt.assert_true,'a' in _ip.user_ns
101 _ip.magic('clear array')
113 _ip.magic('clear array')
102 yield nt.assert_false,'a' in _ip.user_ns
114 yield (nt.assert_false, 'a' in _ip.user_ns)
103
115
104
116
105 @dec.skip()
117 @dec.skip()
General Comments 0
You need to be logged in to leave comments. Login now