HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/qtconsole/tests/test_inprocess_kernel.py
"""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