Skip to content

Commit 072da65

Browse files
committed
Add test_julia_repl.jl
1 parent b509c7b commit 072da65

4 files changed

Lines changed: 52 additions & 9 deletions

File tree

src/IPython.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020

2121
# Register keybind '.' in Julia REPL:
2222

23-
function init_repl_if_not()
23+
function init_repl_if_not(; _init_repl=init_repl)
2424
active_repl = try
2525
Base.active_repl
2626
catch err
@@ -29,7 +29,7 @@ function init_repl_if_not()
2929
end
3030

3131
if isinteractive() && typeof(active_repl) != Base.REPL.BasicREPL
32-
init_repl(active_repl)
32+
_init_repl(active_repl)
3333
end
3434
end
3535
# See: https://github.com/JuliaInterop/RCall.jl/blob/master/src/setup.jl

test/preamble.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@static if VERSION < v"0.7.0-DEV.2005"
2+
using Base.Test
3+
else
4+
using Test
5+
end
6+
7+
using IPython

test/runtests.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# module TestIPython
22

3-
using IPython
4-
import PyCall
5-
@static if VERSION < v"0.7.0-DEV.2005"
6-
using Base.Test
7-
else
8-
using Test
9-
end
3+
include("preamble.jl")
104

5+
import PyCall
116
@show PyCall.pyprogramname
127
@show PyCall.pyversion
138
@show PyCall.libpython
@@ -21,4 +16,6 @@ ipy_main = ipy_opts["user_ns"]["Main"]
2116
@test x == 17061
2217
end
2318

19+
include("test_julia_repl.jl")
20+
2421
# end # module

test/test_julia_repl.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module TestJuliaREPL
2+
3+
include("preamble.jl")
4+
using IPython: init_repl, init_repl_if_not
5+
using Base.Terminals: TextTerminal
6+
7+
8+
@testset "init_repl_if_not" begin
9+
repl = init_repl_if_not(; _init_repl=identity)
10+
if isinteractive()
11+
@test repl === Base.active_repl
12+
else
13+
@test repl === nothing
14+
end
15+
end
16+
17+
18+
struct DummyTerminal <: TextTerminal
19+
end
20+
21+
function dummy_repl()
22+
repl = Base.REPL.LineEditREPL(DummyTerminal())
23+
repl.interface = Base.REPL.setup_interface(repl)
24+
return repl
25+
end
26+
27+
function dummy_initialized_repl()
28+
repl = dummy_repl()
29+
init_repl(repl)
30+
return repl
31+
end
32+
33+
@testset "init_repl" begin
34+
repl = dummy_initialized_repl()
35+
keymap_dict = repl.interface.modes[1].keymap_dict
36+
@test haskey(keymap_dict, '.')
37+
end
38+
39+
end # module

0 commit comments

Comments
 (0)