|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 | from jupyter_client import KernelManager |
| 9 | +from jupyter_client.kernelspec import KernelSpecManager |
9 | 10 | from jupyter_core.paths import secure_write |
10 | 11 | from traitlets.config.loader import Config |
11 | 12 |
|
@@ -133,19 +134,38 @@ def test_trio_loop(): |
133 | 134 |
|
134 | 135 |
|
135 | 136 | 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 | + |
136 | 152 | 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" |
139 | 159 | km.pre_start_kernel() |
140 | 160 |
|
141 | 161 | app = IPKernelApp(connection_file=connection_file) |
142 | 162 | super(IPKernelApp, app).initialize(argv=[""]) |
143 | 163 | app.init_connection_file() |
144 | | - with patch.object(app.log, "debug") as mock_debug: |
| 164 | + with patch.object(app.log, "info") as mock_info: |
145 | 165 | app.init_sockets() |
146 | 166 | app.cleanup_connection_file() |
147 | 167 | 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] |
149 | 169 | assert any("Detected CurveZMQ secret key; using transport encryption" in m for m in messages), ( |
150 | 170 | "Expected a debug log mentioning CurveZMQ when keys are provided" |
151 | 171 | ) |
|
0 commit comments