Skip to content

Commit 210b88e

Browse files
committed
fix tests
1 parent 9780c69 commit 210b88e

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/julia/pyjulia_helper.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ macro prepare_for_pyjulia_call(ex)
8181
""")
8282
end
8383
elseif isexpr(x, :macrocall) && x.args[1]==Symbol("@py_str")
84-
make_pyeval(x.args[3:end]...), false
84+
# in Julia 0.7+, x.args[2] is a LineNumberNode, so filter it out
85+
# in a way that's compatible with Julia 0.6:
86+
make_pyeval(filter(s->(s isa String), x.args[2:end])...), false
8587
else
8688
x, true
8789
end
8890
end
91+
8992
esc(quote
9093
$pyfunction(($globals,$locals) -> (@eval Main $ex), $PyObject, $PyObject)
9194
end)

test/test_magic.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
from IPython.testing.globalipapp import start_ipython as _start_ipython
1+
from textwrap import dedent
2+
3+
import pytest
24
from IPython import get_ipython as _get_ipython
5+
from IPython.testing.globalipapp import start_ipython as _start_ipython
6+
37
from julia import magic
4-
import pytest
8+
59

610
def get_ipython():
711
return _start_ipython() or _get_ipython()
@@ -36,46 +40,46 @@ def test_failure_cell(julia_magics):
3640

3741

3842
def test_interp_var(julia_magics):
39-
assert julia_magics.shell.run_cell("""
43+
assert julia_magics.shell.run_cell(dedent("""
4044
x=1
4145
%julia $x
42-
""").result == 1
46+
""")).result == 1
4347

4448
def test_interp_expr(julia_magics):
45-
assert julia_magics.shell.run_cell("""
49+
assert julia_magics.shell.run_cell(dedent("""
4650
x=1
4751
%julia py"x+1"
48-
""").result == 2
52+
""")).result == 2
4953

5054
def test_bad_interp(julia_magics):
51-
assert julia_magics.shell.run_cell("""
55+
assert julia_magics.shell.run_cell(dedent("""
5256
%julia $(x+1)
53-
""").error_in_exec is not None
57+
""")).error_in_exec is not None
5458

5559
def test_string_interp(julia_magics):
56-
assert julia_magics.shell.run_cell("""
60+
assert julia_magics.shell.run_cell(dedent("""
5761
%julia foo=3; "$foo"
58-
""").result == '3'
62+
""")).result == '3'
5963

6064
def test_interp_escape(julia_magics):
61-
assert julia_magics.shell.run_cell("""
65+
assert julia_magics.shell.run_cell(dedent("""
6266
%julia bar=3; :($$bar)
63-
""").result == 3
67+
""")).result == 3
6468

6569
def test_type_conversion(julia_magics):
66-
assert julia_magics.shell.run_cell("""
70+
assert julia_magics.shell.run_cell(dedent("""
6771
%julia py"1" isa Int && py"1"o isa PyObject
68-
""").result == True
72+
""")).result == True
6973

7074
def test_scoping(julia_magics):
71-
assert julia_magics.shell.run_cell("""
75+
assert julia_magics.shell.run_cell(dedent("""
7276
x = "global"
7377
def f():
7478
x = "local"
7579
ret = %julia py"x"
7680
return ret
7781
f()
78-
""").result == "local"
82+
""")).result == "local"
7983

8084
def test_revise_error():
8185
from julia.ipy import revise

0 commit comments

Comments
 (0)