|
1 |
| -from IPython.testing.globalipapp import start_ipython as _start_ipython |
| 1 | +from textwrap import dedent |
| 2 | + |
| 3 | +import pytest |
2 | 4 | from IPython import get_ipython as _get_ipython
|
| 5 | +from IPython.testing.globalipapp import start_ipython as _start_ipython |
| 6 | + |
3 | 7 | from julia import magic
|
4 |
| -import pytest |
| 8 | + |
5 | 9 |
|
6 | 10 | def get_ipython():
|
7 | 11 | return _start_ipython() or _get_ipython()
|
@@ -36,46 +40,46 @@ def test_failure_cell(julia_magics):
|
36 | 40 |
|
37 | 41 |
|
38 | 42 | def test_interp_var(julia_magics):
|
39 |
| - assert julia_magics.shell.run_cell(""" |
| 43 | + assert julia_magics.shell.run_cell(dedent(""" |
40 | 44 | x=1
|
41 | 45 | %julia $x
|
42 |
| - """).result == 1 |
| 46 | + """)).result == 1 |
43 | 47 |
|
44 | 48 | def test_interp_expr(julia_magics):
|
45 |
| - assert julia_magics.shell.run_cell(""" |
| 49 | + assert julia_magics.shell.run_cell(dedent(""" |
46 | 50 | x=1
|
47 | 51 | %julia py"x+1"
|
48 |
| - """).result == 2 |
| 52 | + """)).result == 2 |
49 | 53 |
|
50 | 54 | def test_bad_interp(julia_magics):
|
51 |
| - assert julia_magics.shell.run_cell(""" |
| 55 | + assert julia_magics.shell.run_cell(dedent(""" |
52 | 56 | %julia $(x+1)
|
53 |
| - """).error_in_exec is not None |
| 57 | + """)).error_in_exec is not None |
54 | 58 |
|
55 | 59 | def test_string_interp(julia_magics):
|
56 |
| - assert julia_magics.shell.run_cell(""" |
| 60 | + assert julia_magics.shell.run_cell(dedent(""" |
57 | 61 | %julia foo=3; "$foo"
|
58 |
| - """).result == '3' |
| 62 | + """)).result == '3' |
59 | 63 |
|
60 | 64 | def test_interp_escape(julia_magics):
|
61 |
| - assert julia_magics.shell.run_cell(""" |
| 65 | + assert julia_magics.shell.run_cell(dedent(""" |
62 | 66 | %julia bar=3; :($$bar)
|
63 |
| - """).result == 3 |
| 67 | + """)).result == 3 |
64 | 68 |
|
65 | 69 | def test_type_conversion(julia_magics):
|
66 |
| - assert julia_magics.shell.run_cell(""" |
| 70 | + assert julia_magics.shell.run_cell(dedent(""" |
67 | 71 | %julia py"1" isa Int && py"1"o isa PyObject
|
68 |
| - """).result == True |
| 72 | + """)).result == True |
69 | 73 |
|
70 | 74 | def test_scoping(julia_magics):
|
71 |
| - assert julia_magics.shell.run_cell(""" |
| 75 | + assert julia_magics.shell.run_cell(dedent(""" |
72 | 76 | x = "global"
|
73 | 77 | def f():
|
74 | 78 | x = "local"
|
75 | 79 | ret = %julia py"x"
|
76 | 80 | return ret
|
77 | 81 | f()
|
78 |
| - """).result == "local" |
| 82 | + """)).result == "local" |
79 | 83 |
|
80 | 84 | def test_revise_error():
|
81 | 85 | from julia.ipy import revise
|
|
0 commit comments