Skip to content

Commit

Permalink
Add test for Jep #65 (#134)
Browse files Browse the repository at this point in the history
* Add test for Jep #65

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add flag to skip iopub welcome message test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add noqa mention

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Hind-M and pre-commit-ci[bot] authored Aug 29, 2023
1 parent bb07b71 commit 78b8f14
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions jupyter_kernel_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,38 @@ def test_clear_output(self):
if not found:
emsg = "clear_output message not found"
raise AssertionError(emsg)


class IopubWelcomeTests(TestCase):
kernel_name = "python3"
kc: BlockingKernelClient
km: KernelManager

@classmethod
def setUpClass(cls):
cls.km = KernelManager(kernel_name=cls.kernel_name)
cls.km.start_kernel()
cls.kc = cls.km.client()

@classmethod
def tearDownClass(cls):
cls.kc.stop_channels()
cls.km.shutdown_kernel()

support_iopub_welcome = False

def test_recv_iopub_welcome_msg(self):
if not self.support_iopub_welcome:
raise SkipTest("Iopub welcome messages are not supported") # noqa

self.kc.start_channels()
while True:
msg = self.kc.get_iopub_msg()
if msg:
self.assertEqual(msg["header"]["msg_type"], "iopub_welcome")
self.assertEqual(msg["msg_type"], "iopub_welcome")
self.assertEqual(
msg["content"]["subscription"], ""
) # Default: empty topic means subscription to all topics

break

0 comments on commit 78b8f14

Please sign in to comment.