通过消息传递协议测试jupyter内核的机器。

jupyter_kernel_test的Python项目详细描述


jupyter_kernel_test是测试Jupyter内核的工具。它测试内核是否成功执行代码,以及是否符合Jupyter Messaging Protocol(当前为5.0)。

安装

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

pip3 install jupyter_kernel_test

用法

要使用它,您需要用相关语言编写一个(python)unittest文件,其中包含测试消息传递协议各个部分的代码示例。下面给出了一个简短的示例,否则您可以查阅test_ipykernel.pytest_irkernel.py文件以获得完整的示例。

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

直接使用python运行这个文件,或者使用nosetestspy.test查找并运行它。

示例

importunittestimportjupyter_kernel_testclassMyKernelTests(jupyter_kernel_test.KernelTests):# Required --------------------------------------# The name identifying an installed kernel to run the tests againstkernel_name="mykernel"# language_info.name in a kernel_info_reply should match thislanguage_name="mylanguage"# Optional --------------------------------------# Code in the kernel's language to write "hello, world" to stdoutcode_hello_world="print 'hello, world'"# Pager: code that should display something (anything) in the pagercode_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 typecode_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.deftest_mykernel_stderr(self):reply,output_msgs=self.execute_helper(code='print_err "oops"')self.assertEqual(output_msgs[0]['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
  • 标准输入:^{TT10}$,^{TT11}$
  • 显示数据元数据
  • 关机/重启:shutdown_requestshutdown_reply
  • 历史:并非涵盖所有选项组合
  • 检查:多级
  • 执行有效载荷(已弃用但仍在使用):有效载荷loadeditask_exit
  • 用户表达式
  • 执行:组合silentstore_historystop_on_error

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
当注释bean用作另一个bean中的集合时,java自定义约束验证器不工作   毕加索中的java错误get()无法应用于(安卓.content.Context)   java RSA Encryption生成带有“\n”字符的字符串,我无法解密   java使用无线路由器访问Wamp   java EhCache磁盘持久性可以持久化任意对象   将文件复制到数组(Java)   Java JScience:如何打印整个实数?   用户界面在JAVA中鼠标点击“设置”按钮时如何获取文本字段内容   JAVA中ArrayList<ArrayList>的深度副本   eclipse的java代码感知样式自动完成   netbeans 7无法从另一个平台运行java项目   hbm中的java异常。xml   java在电子邮件正文中发送HTML   按名称列出的tomcat Java jconsole应用程序   在活动之间传递ArrayList的java机制   Java中long的模运算符是什么?