跳转到主要内容

未提供项目描述

项目描述

安装

使用pip安装(需要python3.4或更高版本)

pip3 install jupyter_kernel_test

使用方法

要使用它,您需要编写一个包含相关语言代码样本的(python)unittest文件,以测试消息协议的各个部分。下面提供了一个简短的示例,您还可以参考test_ipykernel.pytest_irkernel.py文件以获取完整的示例。

消息协议的一些部分仅与基于浏览器的笔记本(富显示)或控制台界面(代码完整性、历史搜索)相关。仅测试您提供的代码样本的部分规范。

直接使用Python运行此文件,或使用nosetestspy.test来查找和运行它。

示例

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()

覆盖率

以下消息协议方面未明确测试

  • 小部件通讯:comm_opencomm_msgcomm_close

  • stdin:input_requestinput_reply

  • display_data元数据

  • 关闭/重启:shutdown_requestshutdown_reply

  • 历史:并非所有选项组合都得到覆盖

  • 检查:多个级别

  • 执行有效载荷(已弃用但仍在使用):有效载荷loadeditask_exit

  • 用户表达式

  • 执行:silentstore_historystop_on_error的组合

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

jupyter_kernel_test-0.7.0.tar.gz (17.1 kB 查看哈希值)

上传时间

构建分发

jupyter_kernel_test-0.7.0-py3-none-any.whl (10.4 kB 查看哈希值)

上传时间 Python 3

由以下组织支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面