Skip to content

Commit

Permalink
Add test of QtInProcessKernelManager
Browse files Browse the repository at this point in the history
  • Loading branch information
rayosborn committed May 5, 2023
1 parent c72ee0f commit c0a1dca
Show file tree
Hide file tree
Showing 2 changed files with 32 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
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 c0a1dca

Please sign in to comment.