File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
3434end
3535# See: https://github.com/JuliaInterop/RCall.jl/blob/master/src/setup.jl
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
2217end
2318
19+ include (" test_julia_repl.jl" )
20+
2421# end # module
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments