##// END OF EJS Templates
Start adding tests for inputtransformer2
Thomas Kluyver -
Show More
@@ -0,0 +1,37 b''
1 import nose.tools as nt
2
3 from IPython.core import inputtransformer2
4 from IPython.core.inputtransformer2 import make_tokens_by_line
5
6 MULTILINE_MAGIC_ASSIGN = ("""\
7 a = f()
8 b = %foo \\
9 bar
10 g()
11 """.splitlines(keepends=True), """\
12 a = f()
13 b = get_ipython().run_line_magic('foo', ' bar')
14 g()
15 """.splitlines(keepends=True))
16
17 MULTILINE_SYSTEM_ASSIGN = ("""\
18 a = f()
19 b = !foo \\
20 bar
21 g()
22 """.splitlines(keepends=True), """\
23 a = f()
24 b = get_ipython().getoutput('foo bar')
25 g()
26 """.splitlines(keepends=True))
27
28 def test_find_assign_magic():
29 tbl = make_tokens_by_line(MULTILINE_MAGIC_ASSIGN[0])
30 nt.assert_equal(inputtransformer2.MagicAssign.find(tbl), (2, 4))
31
32 tbl = make_tokens_by_line(MULTILINE_SYSTEM_ASSIGN[0]) # Nothing to find
33 nt.assert_equal(inputtransformer2.MagicAssign.find(tbl), None)
34
35 def test_transform_assign_magic():
36 res = inputtransformer2.MagicAssign.transform(MULTILINE_MAGIC_ASSIGN[0], (2, 4))
37 nt.assert_equal(res, MULTILINE_MAGIC_ASSIGN[1])
General Comments 0
You need to be logged in to leave comments. Login now