Skip to main content

No project description provided

Project description

jupyter_kernel_test is a tool for testing Jupyter kernels. It tests kernels for successful code execution and conformance with the Jupyter Messaging Protocol (currently 5.0).

Install

Install it with pip (python3.4 or greater required):

pip3 install jupyter_kernel_test

Usage

To use it, you need to write a (python) unittest file containing code samples in the relevant language which test various parts of the messaging protocol. A short example is given below, and you can also refer to the test_ipykernel.py and test_irkernel.py files for complete examples.

Some parts of the messaging protocol are relevant only to the browser-based notebook (rich display) or console interfaces (code completeness, history searching). Only parts of the spec for which you provide code samples are tested.

Run this file directly using python, or use nosetests or py.test to find and run it.

Example

import unittest
import jupyter_kernel_test

class MyKernelTests(jupyter_kernel_test.KernelTests):
    # Required --------------------------------------

    # The name identifying an installed kernel to run the tests against
    kernel_name = "mykernel"

    # language_info.name in a kernel_info_reply should match this
    language_name = "mylanguage"

    # Optional --------------------------------------

    # Code in the kernel's language to write "hello, world" to stdout
    code_hello_world = "print 'hello, world'"

    # Pager: code that should display something (anything) in the pager
    code_page_something = "help(something)"

    # Samples of code which generate a result value (ie, some text
    # displayed as Out[n])
    code_execute_result = [
        {'code': '6*7', 'result': '42'}
    ]

    # Samples of code which should generate a rich display output, and
    # the expected MIME type
    code_display_data = [
        {'code': 'show_image()', 'mime': 'image/png'}
    ]

    # You can also write extra tests. We recommend putting your kernel name
    # in the method name, to avoid clashing with any tests that
    # jupyter_kernel_test adds in the future.
    def test_mykernel_stderr(self):
        self.flush_channels()
        reply, output_msgs = self.execute_helper(code='print_err "oops"')
        self.assertEqual(output_msgs[0]['header']['msg_type'], 'stream')
        self.assertEqual(output_msgs[0]['content']['name'], 'stderr')
        self.assertEqual(output_msgs[0]['content']['text'], 'oops\n')

if __name__ == '__main__':
    unittest.main()

Coverage

The following aspects of the messaging protocol are not explicitly tested:

  • Widget comms: comm_open, comm_msg, comm_close

  • stdin: input_request, input_reply

  • display_data metadata

  • Shutdown/restart: shutdown_request, shutdown_reply

  • History: not all option combinations covered

  • Inspection: multiple levels

  • Execution payloads (deprecated but still used): payloads load, edit, ask_exit

  • User expressions

  • Execution: combinations of silent, store_history and stop_on_error

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_kernel_test-0.4.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_kernel_test-0.4.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_kernel_test-0.4.1.tar.gz.

File metadata

  • Download URL: jupyter_kernel_test-0.4.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for jupyter_kernel_test-0.4.1.tar.gz
Algorithm Hash digest
SHA256 9a184bfb7b7b2ec220a42f88c23f0c2632508b6b89be0439015f14325be91c4c
MD5 87f06593e6595aaf2fb3b11262d5e310
BLAKE2b-256 dd833191307796e98e1f2b69bde1deac1bb3b89e807f33bdf1e90b70d3eb33b9

See more details on using hashes here.

File details

Details for the file jupyter_kernel_test-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: jupyter_kernel_test-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for jupyter_kernel_test-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 416fd3e4caac8e6342ff167f16485bb9d03d30558962e842775725fe655a2dc6
MD5 517703655508e489f8d47f5033978175
BLAKE2b-256 38cc2afa071be957623b9ffd6308fa151f5cae260ccef3bc93b6410dfbbdee0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page