Skip to content

Commit 5481d4b

Browse files
committed
Fix tests
1 parent 04ec2fe commit 5481d4b

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

tests/test_curve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _make_app(tmp_path, *, enable_curve=False, **kwargs):
180180
if enable_curve:
181181
# Populate the Curve keys into the connection file
182182
km = KernelManager(connection_file=connection_file_path)
183-
km.transport_encryption = True
183+
km.transport_encryption = "enabled"
184184
km.pre_start_kernel()
185185

186186
app = IPKernelApp(connection_file=connection_file_path, **kwargs)

tests/test_kernelapp.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pytest
88
from jupyter_client import KernelManager
9+
from jupyter_client.kernelspec import KernelSpecManager
910
from jupyter_core.paths import secure_write
1011
from traitlets.config.loader import Config
1112

@@ -133,19 +134,38 @@ def test_trio_loop():
133134

134135

135136
def test_init_sockets_curve_enabled_logs_debug(tmp_path):
137+
kernel_name = "curve-test"
138+
kernels_dir = tmp_path / "kernels"
139+
kernel_dir = kernels_dir / kernel_name
140+
kernel_dir.mkdir(parents=True)
141+
with (kernel_dir / "kernel.json").open("w") as f:
142+
json.dump(
143+
{
144+
"argv": ["python", "-m", "ipykernel_launcher", "-f", "{connection_file}"],
145+
"display_name": "curve-test",
146+
"language": "python",
147+
"metadata": {"supported_encryption": "curve"},
148+
},
149+
f,
150+
)
151+
136152
connection_file = str(tmp_path / "kernel.json")
137-
km = KernelManager(connection_file=connection_file)
138-
km.transport_encryption = True
153+
km = KernelManager(
154+
connection_file=connection_file,
155+
kernel_name=kernel_name,
156+
kernel_spec_manager=KernelSpecManager(kernel_dirs=[str(kernels_dir)]),
157+
)
158+
km.transport_encryption = "enabled"
139159
km.pre_start_kernel()
140160

141161
app = IPKernelApp(connection_file=connection_file)
142162
super(IPKernelApp, app).initialize(argv=[""])
143163
app.init_connection_file()
144-
with patch.object(app.log, "debug") as mock_debug:
164+
with patch.object(app.log, "info") as mock_info:
145165
app.init_sockets()
146166
app.cleanup_connection_file()
147167
app.close()
148-
messages = [str(call) for call in mock_debug.call_args_list]
168+
messages = [str(call) for call in mock_info.call_args_list]
149169
assert any("Detected CurveZMQ secret key; using transport encryption" in m for m in messages), (
150170
"Expected a debug log mentioning CurveZMQ when keys are provided"
151171
)

0 commit comments

Comments
 (0)