Skip to content

Commit dccf9c3

Browse files
committed
add regression test
1 parent b8f5dfc commit dccf9c3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_start_kernel.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,36 @@ def test_ipython_start_kernel_userns():
5050
assert EXPECTED in text
5151

5252

53+
def test_start_kernel_background_thread():
54+
55+
cmd = dedent(
56+
"""
57+
import threading
58+
from ipykernel.kernelapp import launch_new_instance
59+
60+
def launch():
61+
launch_new_instance()
62+
63+
thread = threading.Thread(target=launch)
64+
thread.start()
65+
thread.join()
66+
"""
67+
)
68+
69+
with setup_kernel(cmd) as client:
70+
client.execute("a = 1")
71+
msg = client.get_shell_msg(timeout=TIMEOUT)
72+
content = msg["content"]
73+
assert content["status"] == "ok"
74+
75+
client.inspect("a")
76+
msg = client.get_shell_msg(timeout=TIMEOUT)
77+
content = msg["content"]
78+
assert content["found"]
79+
text = content["data"]["text/plain"]
80+
assert "1" in text
81+
82+
5383
@pytest.mark.flaky(max_runs=3)
5484
def test_ipython_start_kernel_no_userns():
5585
# Issue #4188 - user_ns should be passed to shell as None, not {}

0 commit comments

Comments
 (0)