Skip to content

Commit

Permalink
Isolate each subshell test
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 committed Aug 7, 2024
1 parent 938e844 commit 819aa90
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/test_subshells.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest
from jupyter_client.blocking.client import BlockingKernelClient

from .utils import TIMEOUT, get_replies, get_reply, kernel, new_kernel
from .utils import TIMEOUT, get_replies, get_reply, new_kernel

# Helpers

Expand Down Expand Up @@ -76,15 +76,15 @@ def execute_thread_ids(kc: BlockingKernelClient, subshell_id: str | None = None)


def test_supported():
with kernel() as kc:
with new_kernel() as kc:
msg_id = kc.kernel_info()
reply = get_reply(kc, msg_id, TIMEOUT)
assert "supported_features" in reply["content"]
assert "kernel subshells" in reply["content"]["supported_features"]


def test_subshell_id_lifetime():
with kernel() as kc:
with new_kernel() as kc:
assert list_subshell_helper(kc)["subshell_id"] == []
subshell_id = create_subshell_helper(kc)["subshell_id"]
assert list_subshell_helper(kc)["subshell_id"] == [subshell_id]
Expand All @@ -93,14 +93,14 @@ def test_subshell_id_lifetime():


def test_delete_non_existent():
with kernel() as kc:
with new_kernel() as kc:
reply = delete_subshell_helper(kc, "unknown_subshell_id")
assert reply["status"] == "error"
assert "evalue" in reply


def test_thread_counts():
with kernel() as kc:
with new_kernel() as kc:
nthreads = execute_thread_count(kc)

subshell_id = create_subshell_helper(kc)["subshell_id"]
Expand All @@ -113,7 +113,7 @@ def test_thread_counts():


def test_thread_ids():
with kernel() as kc:
with new_kernel() as kc:
subshell_id = create_subshell_helper(kc)["subshell_id"]

thread_id, main_thread_id = execute_thread_ids(kc)
Expand All @@ -128,7 +128,7 @@ def test_thread_ids():
@pytest.mark.parametrize("are_subshells", [(False, True), (True, False), (True, True)])
@pytest.mark.parametrize("overlap", [True, False])
def test_run_concurrently_sequence(are_subshells, overlap):
with kernel() as kc:
with new_kernel() as kc:
subshell_ids = [
create_subshell_helper(kc)["subshell_id"] if is_subshell else None
for is_subshell in are_subshells
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_run_concurrently_sequence(are_subshells, overlap):

@pytest.mark.parametrize("include_main_shell", [True, False])
def test_run_concurrently_timing(include_main_shell):
with kernel() as kc:
with new_kernel() as kc:
subshell_ids = [
None if include_main_shell else create_subshell_helper(kc)["subshell_id"],
create_subshell_helper(kc)["subshell_id"],
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_run_concurrently_timing(include_main_shell):


def test_execution_count():
with kernel() as kc:
with new_kernel() as kc:
subshell_id = create_subshell_helper(kc)["subshell_id"]

# Prepare messages
Expand All @@ -230,7 +230,7 @@ def test_execution_count():


def test_create_while_execute():
with kernel() as kc:
with new_kernel() as kc:
# Send request to execute code on main subshell.
msg = kc.session.msg("execute_request", {"code": "import time; time.sleep(0.05)"})
kc.shell_channel.send(msg)
Expand Down

0 comments on commit 819aa90

Please sign in to comment.