Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing closed method to QtInProcessChannel #575

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ __pycache__
.#*
.coverage
.pytest_cache
.vscode
4 changes: 4 additions & 0 deletions qtconsole/inprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def flush(self, timeout=1.0):
super().flush()
self.process_events()

def closed(self):
""" Function to ensure compatibility with the QtZMQSocketChannel."""
return False


class QtInProcessHBChannel(SuperQObject, InProcessHBChannel):
# This signal will never be fired, but it needs to exist
Expand Down
31 changes: 31 additions & 0 deletions qtconsole/tests/test_inprocess_kernel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Test QtInProcessKernel"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import unittest

from qtconsole.inprocess import QtInProcessKernelManager


class InProcessTests(unittest.TestCase):

def setUp(self):
"""Open an in-process kernel."""
self.kernel_manager = QtInProcessKernelManager()
self.kernel_manager.start_kernel()
self.kernel_client = self.kernel_manager.client()

def tearDown(self):
"""Shutdown the in-process kernel. """
self.kernel_client.stop_channels()
self.kernel_manager.shutdown_kernel()

def test_execute(self):
"""Test execution of shell commands."""
# check that closed works as expected
assert not self.kernel_client.iopub_channel.closed()

# check that running code works
self.kernel_client.execute('a=1')
assert self.kernel_manager.kernel.shell.user_ns.get('a') == 1