Skip to content

Commit f6d3a7c

Browse files
authored
Merge pull request #629 from Carreau/maybe-async
Test async kernel manager
2 parents da050c9 + c9eeecc commit f6d3a7c

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

.github/workflows/linux-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
PYTHON_VERSION: ['3.8', '3.9', '3.10', '3.11']
30+
PYTHON_VERSION: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
3131
INSTALL_TYPE: ['conda', 'pip']
3232
QT_LIB: ['pyqt5', 'pyqt6']
3333
exclude:

qtconsole/tests/test_inprocess_kernel.py

+24-25
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@
33
# Copyright (c) Jupyter Development Team.
44
# Distributed under the terms of the Modified BSD License.
55

6-
import unittest
7-
86
from qtconsole.inprocess import QtInProcessKernelManager
9-
10-
11-
class InProcessTests(unittest.TestCase):
12-
13-
def setUp(self):
14-
"""Open an in-process kernel."""
15-
self.kernel_manager = QtInProcessKernelManager()
16-
self.kernel_manager.start_kernel()
17-
self.kernel_client = self.kernel_manager.client()
18-
19-
def tearDown(self):
20-
"""Shutdown the in-process kernel. """
21-
self.kernel_client.stop_channels()
22-
self.kernel_manager.shutdown_kernel()
23-
24-
def test_execute(self):
25-
"""Test execution of shell commands."""
26-
# check that closed works as expected
27-
assert not self.kernel_client.iopub_channel.closed()
28-
29-
# check that running code works
30-
self.kernel_client.execute('a=1')
31-
assert self.kernel_manager.kernel.shell.user_ns.get('a') == 1
7+
from inspect import iscoroutinefunction
8+
import pytest
9+
10+
11+
@pytest.mark.asyncio
12+
async def test_execute():
13+
kernel_manager = QtInProcessKernelManager()
14+
if iscoroutinefunction(kernel_manager.start_kernel):
15+
await kernel_manager.start_kernel()
16+
else:
17+
kernel_manager.start_kernel()
18+
kernel_client = kernel_manager.client()
19+
20+
"""Test execution of shell commands."""
21+
# check that closed works as expected
22+
assert not kernel_client.iopub_channel.closed()
23+
24+
# check that running code works
25+
kernel_client.execute("a=1")
26+
assert kernel_manager.kernel is not None, "kernel has likely not started"
27+
assert kernel_manager.kernel.shell.user_ns.get("a") == 1
28+
29+
kernel_client.stop_channels()
30+
kernel_manager.shutdown_kernel()

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@
7474
'qtpy>=2.4.0',
7575
'packaging'
7676
],
77-
extras_require = {
78-
'test': ['flaky', 'pytest', 'pytest-qt'],
79-
'doc': 'Sphinx>=1.3',
77+
extras_require={
78+
"test": ["flaky", "pytest", "pytest-qt", "pytest-asyncio"],
79+
"doc": "Sphinx>=1.3",
8080
},
8181
entry_points = {
8282
'gui_scripts': [

0 commit comments

Comments
 (0)