Skip to content

Commit 2b8bd55

Browse files
author
Christopher Doris
committed
only test PyCall when we can guarantee same interpreter
1 parent 4c59982 commit 2b8bd55

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

test/Compat.jl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,21 @@ end
3939
end
4040

4141
@testitem "PyCall.jl" begin
42-
using PyCall
43-
same = Base.get_extension(PythonCall, :PyCallExt).SAME[]::Bool
44-
@info "testing PyCall" same
45-
if get(ENV, "CI", "") != ""
46-
# ensure we test both `same` and `!same` in CI
47-
@test same == (ENV["JULIA_PYTHONCALL_EXE"] == "python")
48-
end
49-
if same
42+
if (get(ENV, "CI", "") != "") && (ENV["JULIA_PYTHONCALL_EXE"] == "python")
43+
# Only run this test when we can guarantee PyCall and PythonCall are using the
44+
# same Python. Currently this only runs in CI, and if PythonCall is using the
45+
# system Python installation.
46+
using PyCall
47+
# Check they are indeed using the same Python.
48+
@test Base.get_extension(PythonCall, :PyCallExt).SAME[]
49+
# Check we can round-trip and object PythonCall -> PyCall -> PythonCall and
50+
# have the same identical Python object afterward.
5051
x1 = pylist()::Py
5152
x2 = PyCall.PyObject(x1)::PyCall.PyObject
5253
x3 = Py(x2)::Py
5354
@test pyis(x3, x1)
5455
else
55-
x1 = pylist()::Py
56-
@test_throws "only possible when using the same Python" PyCall.PyObject(x1)
57-
x2 = PyCall.pybuiltin("list")()::PyCall.PyObject
58-
@test_throws "only possible when using the same Python" Py(x2)
56+
@warn "Skipping PyCall.jl tests."
5957
end
6058
end
6159

0 commit comments

Comments
 (0)