Skip to content

Commit 33a9c67

Browse files
committed
Add test
1 parent 64bf6b5 commit 33a9c67

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

pytest/test_all.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,45 @@ def test_call_nogil(yld, raw):
168168
t2 = time() - t0
169169
# executing the tasks should take about 1 second because they happen in parallel
170170
assert 0.9 < t2 < 1.5
171+
172+
173+
def test_repl():
174+
import sys
175+
import tomllib
176+
import juliapkg
177+
import juliacall as _
178+
import subprocess
179+
import time
180+
181+
jl_version = juliapkg.state.STATE["version"]
182+
183+
# grab PythonCall.jl version from pyproject.toml
184+
with open("pyproject.toml", "rb") as f:
185+
pyproject = tomllib.load(f)
186+
pythoncall_version = pyproject["project"]["version"]
187+
188+
cmd = [sys.executable, '-m', 'juliacall']
189+
process = subprocess.Popen(
190+
cmd,
191+
stdin=subprocess.PIPE,
192+
stdout=subprocess.PIPE,
193+
stderr=subprocess.PIPE,
194+
text=True,
195+
bufsize=1
196+
)
197+
output = ""
198+
timestart = time.time()
199+
while time.time() - timestart < 100:
200+
char = process.stdout.read(1)
201+
if not char:
202+
break
203+
output += char
204+
if output.endswith("julia>"):
205+
break
206+
assert f"Julia: {jl_version}" in output
207+
assert f"PythonCall: {pythoncall_version}" in output
208+
assert "julia>" in output
209+
process.stdin.write('\x04') # Ctrl+D
210+
process.stdin.flush()
211+
process.wait()
212+
assert process.returncode == 0

0 commit comments

Comments
 (0)