From c0a1dca9e08f998bf88c79ce5af307404d60c3ba Mon Sep 17 00:00:00 2001 From: Ray Osborn Date: Fri, 5 May 2023 10:36:29 -0500 Subject: [PATCH] Add test of QtInProcessKernelManager --- .gitignore | 1 + qtconsole/tests/test_inprocess_kernel.py | 31 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 qtconsole/tests/test_inprocess_kernel.py diff --git a/.gitignore b/.gitignore index 5ed2aa35..c18177c9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ __pycache__ .#* .coverage .pytest_cache +.vscode diff --git a/qtconsole/tests/test_inprocess_kernel.py b/qtconsole/tests/test_inprocess_kernel.py new file mode 100644 index 00000000..a6f9d860 --- /dev/null +++ b/qtconsole/tests/test_inprocess_kernel.py @@ -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