Show More
@@ -5,6 +5,7 more complex. See test_inputtransformer2_line for tests for line-based | |||
|
5 | 5 | transformations. |
|
6 | 6 | """ |
|
7 | 7 | import nose.tools as nt |
|
8 | import string | |
|
8 | 9 | |
|
9 | 10 | from IPython.core import inputtransformer2 as ipt2 |
|
10 | 11 | from IPython.core.inputtransformer2 import make_tokens_by_line |
@@ -100,6 +101,16 b) = zip? | |||
|
100 | 101 | [r"get_ipython().set_next_input('(a,\nb) = zip');get_ipython().run_line_magic('pinfo', 'zip')" + "\n"] |
|
101 | 102 | ) |
|
102 | 103 | |
|
104 | def check_make_token_by_line_never_ends_empty(): | |
|
105 | """ | |
|
106 | Check that not sequence of single or double characters ends up leading to en empty list of tokens | |
|
107 | """ | |
|
108 | from string import printable | |
|
109 | for c in printable: | |
|
110 | nt.assert_not_equal(make_tokens_by_line(c)[-1], []) | |
|
111 | for k in printable: | |
|
112 | nt.assert_not_equal(make_tokens_by_line(c+k)[-1], []) | |
|
113 | ||
|
103 | 114 | def check_find(transformer, case, match=True): |
|
104 | 115 | sample, expected_start, _ = case |
|
105 | 116 | tbl = make_tokens_by_line(sample) |
@@ -190,6 +201,17 def test_check_complete(): | |||
|
190 | 201 | nt.assert_equal(cc("for a in range(5):"), ('incomplete', 4)) |
|
191 | 202 | nt.assert_equal(cc("raise = 2"), ('invalid', None)) |
|
192 | 203 | nt.assert_equal(cc("a = [1,\n2,"), ('incomplete', 0)) |
|
204 | nt.assert_equal(cc(")"), ('incomplete', 0)) | |
|
205 | nt.assert_equal(cc("\\\r\n"), ('incomplete', 0)) | |
|
193 | 206 | nt.assert_equal(cc("a = '''\n hi"), ('incomplete', 3)) |
|
194 | 207 | nt.assert_equal(cc("def a():\n x=1\n global x"), ('invalid', None)) |
|
195 | 208 | nt.assert_equal(cc("a \\ "), ('invalid', None)) # Nothing allowed after backslash |
|
209 | ||
|
210 | # no need to loop on all the letters/numbers. | |
|
211 | short = '12abAB'+string.printable[62:] | |
|
212 | for c in short: | |
|
213 | # test does not raise: | |
|
214 | cc(c) | |
|
215 | for k in short: | |
|
216 | cc(c+k) | |
|
217 |
General Comments 0
You need to be logged in to leave comments.
Login now