Skip to content

Commit

Permalink
Merge pull request #575 from rayosborn/fix-inprocess-channel
Browse files Browse the repository at this point in the history
Add missing `closed` method to `QtInProcessChannel`
  • Loading branch information
ccordoba12 authored May 5, 2023
2 parents 949c0ec + c0a1dca commit c03c57e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
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

0 comments on commit c03c57e

Please sign in to comment.