forked from JuliaPy/PyCall.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pyfncall.jl
37 lines (32 loc) · 984 Bytes
/
test_pyfncall.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Test, PyCall
py"""
def mklist(*args, **kwargs):
l = list(args)
l.extend(kwargs.items())
return l
"""
@testset "pycall!" begin
pymklist = py"mklist"
ret = PyNULL()
function pycall_checks(res, pyf, RetType, args...; kwargs...)
pycall_res = pycall(pyf, RetType, args...; kwargs...)
res_converted = pycall!(res, pyf, RetType, args...; kwargs...)
@test res_converted == pycall_res
@test convert(RetType, res) == res_converted
RetType != PyAny && @test res_converted isa RetType
end
@testset "basics" begin
args = ("a", 2, 4.5)
for RetType in (PyObject, PyAny, Tuple)
pycall_checks(ret, pymklist, RetType, args...)
GC.gc()
end
end
@testset "kwargs" begin
args = ("a", 2, 4.5)
for RetType in (PyObject, PyAny, Tuple)
pycall_checks(ret, pymklist, RetType, args...; b=19610, c="5")
GC.gc()
end
end
end