• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_log_text函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中metakernel.tests.utils.get_log_text函数的典型用法代码示例。如果您正苦于以下问题:Python get_log_text函数的具体用法?Python get_log_text怎么用?Python get_log_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_log_text函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_misc

def test_misc():
    class TestKernel(MetaKernel):
        def do_execute_file(self, filename):
            self.Print("This language does not support running files")

        def do_function_direct(self, f, arg):
            self.Print("%s(%s)" % (f, self.repr(arg)))

        def repr(self, arg):
            return "XXX"

    kernel = get_kernel(TestKernel)
    assert kernel.do_execute_direct('garbage') is None
    kernel.do_execute_file('hello.txt')
    assert "This language does not support" in get_log_text(kernel)

    clear_log_text(kernel)

    kernel.do_function_direct('hello', 'world')
    text = get_log_text(kernel)
    assert "hello(XXX)" in text, text
    kernel.restart_kernel()

    ret = kernel.do_is_complete('hello\n')
    assert ret == {'status': 'complete'}

    assert kernel.do_inspect('hello', 10) is None
开发者ID:dsblank,项目名称:metakernel,代码行数:27,代码来源:test_metakernel.py


示例2: test_inline_plots

def test_inline_plots():
    kernel = get_kernel(GnuplotKernel)
    kernel.call_magic('%gnuplot inline')

    # inline plot creates data
    code = """
    plot sin(x)
    """
    kernel.do_execute(code)
    text = get_log_text(kernel)
    assert_true('Display Data' in text)
    clear_log_text(kernel)

    # multiple plot statements data
    code = """
    plot sin(x)
    plot cos(x)
    """
    kernel.do_execute(code)
    text = get_log_text(kernel)
    assert_true(text.count('Display Data') == 2)
    clear_log_text(kernel)

    # svg
    kernel.call_magic('%gnuplot inline svg')
    code = """
    plot tan(x)
    """
    kernel.do_execute(code)
    text = get_log_text(kernel)
    assert_true('Display Data' in text)
    clear_log_text(kernel)
开发者ID:Naereen,项目名称:gnuplot_kernel,代码行数:32,代码来源:test_kernel.py


示例3: test_shell_magic2

def test_shell_magic2():
    kernel = get_kernel()
    kernel.do_execute('!cat "%s"' % __file__, False)
    log_text = get_log_text(kernel)
    assert "metakernel.py" in log_text

    kernel.do_execute('!!\necho "hello"\necho "goodbye"', None)
    log_text = get_log_text(kernel)
    assert '"hello"' in log_text
    assert '"goodbye"' in log_text
开发者ID:Foucl,项目名称:metakernel,代码行数:10,代码来源:test_shell_magic.py


示例4: test_python_magic2

def test_python_magic2():
    kernel = get_kernel()
    kernel.do_execute('%python retval = 1', None)
    assert '1' in get_log_text(kernel)

    kernel.do_execute('''%%python
        def test(a):
            return a + 1
        retval = test(2)''', None)
    assert '3' in get_log_text(kernel)
开发者ID:Foucl,项目名称:metakernel,代码行数:10,代码来源:test_python_magic.py


示例5: test_sticky_magics

def test_sticky_magics():
    kernel = get_kernel()
    kernel.do_execute('%%%html\nhello', None)
    text = get_log_text(kernel)

    assert 'html added to session magics' in text
    kernel.do_execute('<b>hello</b>', None)
    kernel.do_execute('%%%html', None)
    text = get_log_text(kernel)
    assert text.count('Display Data') == 2
    assert 'html removed from session magics' in text
开发者ID:evhub,项目名称:metakernel,代码行数:11,代码来源:test_metakernel.py


示例6: test_ls_magic

def test_ls_magic():
    kernel = get_kernel()
    kernel.do_execute("%ls /tmp")
    text = get_log_text(kernel)
    assert text.startswith("/tmp/"), text[:100]
    clear_log_text(kernel)

    kernel.do_execute("%ls /tmp --recursive")
    text = get_log_text(kernel)
    assert text.startswith("/tmp/"), text[:100]
    clear_log_text(kernel)
开发者ID:a-rodin,项目名称:metakernel,代码行数:11,代码来源:test_ls_magic.py


示例7: test_ls_magic

def test_ls_magic():
    kernel = get_kernel()
    kernel.do_execute("%ls /tmp")
    text = get_log_text(kernel)
    assert '/tmp/' in text, text[:100]
    clear_log_text(kernel)

    kernel.do_execute("%ls /tmp --recursive")
    text = get_log_text(kernel)
    assert '/tmp' in text, text[:100]
    clear_log_text(kernel)
开发者ID:evhub,项目名称:metakernel,代码行数:11,代码来源:test_ls_magic.py


示例8: test_run_magic

def test_run_magic():
    kernel = get_kernel(EvalKernel)
    kernel.do_execute("%%run %s" % __file__.replace(".pyc", ".py"))
    kernel.do_execute("TEST")
    text = get_log_text(kernel)
    assert '42' in text, "Didn't run this file"

    clear_log_text(kernel)
    kernel.do_execute("%%run --language python %s" % __file__.replace(".pyc", ".py"))
    kernel.do_execute("TEST")
    text = get_log_text(kernel)
    assert '42' in text, "Didn't run this file"
开发者ID:Calysto,项目名称:metakernel,代码行数:12,代码来源:test_run_magic.py


示例9: test_download_magic

def test_download_magic():
    kernel = get_kernel(EvalKernel)
    kernel.do_execute("%download --filename TEST.txt https://raw.githubusercontent.com/calysto/metakernel/master/LICENSE.txt")
    text = get_log_text(kernel)
    assert "Downloaded 'TEST.txt'" in text, text
    assert os.path.isfile("TEST.txt"), "File does not exist: TEST.txt"

    clear_log_text(kernel)

    kernel.do_execute("%download https://raw.githubusercontent.com/calysto/metakernel/master/LICENSE.txt")
    text = get_log_text(kernel)
    assert "Downloaded 'LICENSE.txt'" in text, text
    assert os.path.isfile("LICENSE.txt"), "File does not exist: LICENSE.txt"
开发者ID:dsblank,项目名称:metakernel,代码行数:13,代码来源:test_download_magic.py


示例10: test_latex_magic

def test_latex_magic():
    kernel = get_kernel()
    kernel.do_execute("%latex x_1 = \dfrace{a}{b}")
    text = get_log_text(kernel)
    assert "Display Data" in text

    clear_log_text(kernel)

    kernel.do_execute("""%%latex
            x_1 = \dfrac{a}{b}

            x_2 = a^{n - 1}""")
    text = get_log_text(kernel)
    assert "Display Data" in text
开发者ID:Calysto,项目名称:metakernel,代码行数:14,代码来源:test_latex_magic.py


示例11: test_process_metakernel

def test_process_metakernel():
    kernel = get_kernel(BashKernel)
    kernel.do_execute('cat "%s"' % __file__, False)
    log_text = get_log_text(kernel)
    assert "metakernel.py" in log_text, log_text

    kernel.do_execute('echo "hello"\necho "goodbye"', None)
    log_text = get_log_text(kernel)
    assert '"hello"' in log_text
    assert '"goodbye"' in log_text

    kernel.do_execute("lalkjds")
    text = get_log_text(kernel)
    assert ": command not found" in text, text
开发者ID:schlichtanders,项目名称:metakernel,代码行数:14,代码来源:test_process_metakernel.py


示例12: test_cell_magic

def test_cell_magic():
    # To simulate '%load_ext gnuplot_kernel';
    # create a main kernel, a gnuplot kernel and
    # a gnuplot magic that uses the gnuplot kernel.
    # Then manually register the gnuplot magic into
    # the main kernel.
    kernel = get_kernel()
    gkernel = GnuplotKernel()
    gmagic = GnuplotMagic(gkernel)
    gkernel.makeSubkernelTo(kernel, kernel.Display)
    kernel.line_magics['gnuplot'] = gmagic
    kernel.cell_magics['gnuplot'] = gmagic

    # inline output
    code = """%%gnuplot
    plot cos(x)
    """
    kernel.do_execute(code)
    assert_true('Display Data' in get_log_text(kernel))
    clear_log_text(kernel)

    # file output
    kernel.call_magic('%gnuplot pngcairo size 560,420')
    code = """%%gnuplot
    set output 'cosine.png'
    plot cos(x)
    """
    kernel.do_execute(code)
    assert_true(os.path.exists('cosine.png'))
    clear_log_text(kernel)
开发者ID:Naereen,项目名称:gnuplot_kernel,代码行数:30,代码来源:test_kernel.py


示例13: test_reload_magics_magic

def test_reload_magics_magic():
    kernel = get_kernel()
    kernel.do_execute("%reload_magics")
    text = get_log_text(kernel)

    for item in "%cd %connect_info %download %edit %help %html %install_magic %javascript %kernel %kx %latex %load %lsmagic %magic %parallel %plot %pmap %px %python %reload_magics %restart %run %shell %spell %%debug %%file %%help %%html %%javascript %%kx %%latex %%processing %%px %%python %%shell %%show %%spell %%time".split():
        assert item in text, ("load_magic didn't list '%s'" % item)
开发者ID:a-rodin,项目名称:metakernel,代码行数:7,代码来源:test_reload_magics_magic.py


示例14: test_cd_magic

def test_cd_magic():
    kernel = get_kernel()
    kernel.do_execute("%cd ~")
    assert os.getcwd() == os.path.expanduser('~'), os.getcwd()
    clear_log_text(kernel)
    kernel.do_execute('%cd')
    assert os.getcwd() in get_log_text(kernel)
开发者ID:Calysto,项目名称:metakernel,代码行数:7,代码来源:test_cd_magic.py


示例15: test_inspect

def test_inspect():
    kernel = get_kernel()
    kernel.do_inspect('%lsmagic', len('%lsmagic'))
    log_text = get_log_text(kernel)
    assert "list the current line and cell magics" in log_text

    kernel.do_inspect('%lsmagic ', len('%lsmagic') + 1)
开发者ID:evhub,项目名称:metakernel,代码行数:7,代码来源:test_metakernel.py


示例16: test_gnuplot_error_message

def test_gnuplot_error_message():
    kernel = get_kernel(GnuplotKernel)

    # The error messages gets to the kernel
    code = 'plot [1,2][] sin(x)'
    kernel.do_execute(code)
    text = get_log_text(kernel)
    assert_true(' ^' in text)
开发者ID:Naereen,项目名称:gnuplot_kernel,代码行数:8,代码来源:test_kernel.py


示例17: test_process_metakernel

def test_process_metakernel():
    kernel = get_kernel(BashKernel)
    kernel.do_execute("cat \"%s\"" % __file__, False)
    log_text = get_log_text(kernel)
    assert 'metakernel.py' in log_text, log_text

    kernel.do_execute('echo "hello"\necho "goodbye"', None)
    log_text = get_log_text(kernel)
    assert '"hello"' in log_text
    assert '"goodbye"' in log_text

    kernel.do_execute('lalkjds')
    text = get_log_text(kernel)
    assert ': command not found' in text, text
    
    html = HTML("some html")
    kernel.Display(html)
开发者ID:Foucl,项目名称:metakernel,代码行数:17,代码来源:test_process_metakernel.py


示例18: test_javascript_magic

def test_javascript_magic():
    kernel = get_kernel(EvalKernel)
    kernel.do_execute("""%%javascript

console.log("Hello from Javascript");
""")
    text = get_log_text(kernel)
    assert "Display Data" in text, text
开发者ID:Calysto,项目名称:metakernel,代码行数:8,代码来源:test_javascript_magic.py


示例19: test_parallel_magic

def test_parallel_magic():
    kernel = get_kernel(EvalKernel)
    # start up an EvalKernel on each node:
    kernel.do_execute("%parallel metakernel_python MetaKernelPython", False)
    # Now, execute something on each one:
    kernel.do_execute("%px cluster_rank", False)
    results = get_log_text(kernel)
    assert "[0, 1, 2]" in results, results
开发者ID:Foucl,项目名称:metakernel,代码行数:8,代码来源:test_parallel_magic.py


示例20: test_html_magic

def test_html_magic():
    kernel = get_kernel(EvalKernel)
    kernel.do_execute("""%%html

<b>bold</b>
""")
    text = get_log_text(kernel)
    assert "Display Data" in text, text
开发者ID:Calysto,项目名称:metakernel,代码行数:8,代码来源:test_html_magic.py



注:本文中的metakernel.tests.utils.get_log_text函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python metallicity.printsafemulti函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_kernel函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap