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

Python pytest.dbgfunc函数代码示例

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

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



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

示例1: test_contents_good_str

def test_contents_good_str(ctest):
    """
    Calling contents on a file that exists as a string
    """
    pytest.dbgfunc()
    result = tbx.contents(ctest.data.strpath)
    assert result == ctest.exp
开发者ID:tbarron,项目名称:tbx,代码行数:7,代码来源:test_tbx.py


示例2: test_contents_good_list

def test_contents_good_list(ctest):
    """
    Calling contents on a file that exists as a list
    """
    pytest.dbgfunc()
    result = tbx.contents(ctest.data.strpath, fmt='list')
    assert result == ctest.exp.split('\n')
开发者ID:tbarron,项目名称:tbx,代码行数:7,代码来源:test_tbx.py


示例3: test_nodoc

def test_nodoc():
    """
    Report routines missing a doc string
    """
    pytest.dbgfunc()

    # get our bearings -- where is hpssic?
    hpssic_dir = U.dirname(sys.modules['hpssic'].__file__)

    excludes = ['setup.py', '__init__.py']

    # up a level from there, do we have a '.git' directory? That is, are we in
    # a git repository? If so, we want to talk the whole repo for .py files
    hpssic_par = U.dirname(hpssic_dir)
    if not os.path.isdir(U.pathjoin(hpssic_par, ".git")):
        # otherwise, we just work from hpssic down
        wroot = hpssic_dir
    else:
        wroot = hpssic_par

    # collect all the .py files in pylist
    pylist = []
    for r, dlist, flist in os.walk(wroot):
        if '.git' in dlist:
            dlist.remove('.git')
        pylist.extend([U.pathjoin(r, x)
                       for x in flist
                       if x.endswith('.py') and x not in excludes])

    # make a list of the modules implied in pylist in mdict. Each module name
    # is a key. The associated value is False until the module is checked.
    mlist = ['hpssic']
    for path in pylist:
        # Throw away the hpssic parent string, '.py' at the end, and split on
        # '/' to get a list of the module components
        mp = path.replace(hpssic_par + '/', '').replace('.py', '').split('/')

        if 1 < len(mp):
            fromlist = ['hpssic']
        else:
            fromlist = []
        mname = '.'.join(mp)
        if mname.startswith('hpssic'):
            mlist.append(mname)
        if mname not in sys.modules and mname.startswith('hpssic'):
            try:
                __import__(mname, fromlist=fromlist)

            except ImportError:
                pytest.fail('Failure trying to import %s' % mname)

    result = ''
    for m in mlist:
        result += nodoc_check(sys.modules[m], pylist, 0, 't')

    # result = nodoc_check(hpssic, 0, 't')
    if result != '':
        result = "The following functions need doc strings:\n" + result
        pytest.fail(result)
开发者ID:ORNL-TechInt,项目名称:hpss-crawler,代码行数:59,代码来源:test_0_script.py


示例4: test_run_fail

def test_run_fail():
    """
    Run a binary that doesn't exist
    """
    pytest.dbgfunc()
    r = tbx.run("nosuchbinary")
    assert "ERR:" in r
    assert "No such file or directory" in r
开发者ID:tbarron,项目名称:gitr,代码行数:8,代码来源:test_tbx.py


示例5: test_run_stderr

def test_run_stderr():
    """
    Run a process and capture stdout
    """
    pytest.dbgfunc()
    r = tbx.run("ls --nosuch")
    assert "ERR:" in r
    assert re.findall("(illegal|unrecognized) option", r)
开发者ID:tbarron,项目名称:gitr,代码行数:8,代码来源:test_tbx.py


示例6: test_contents_badfmt

def test_contents_badfmt(ctest):
    """
    Calling contents on a file that exists as a list
    """
    pytest.dbgfunc()
    with pytest.raises(tbx.Error) as err:
        _ = tbx.contents(ctest.data.strpath, fmt='str', sep=r'\s')
    assert 'Non-default separator is only valid for list format' in str(err)
开发者ID:tbarron,项目名称:tbx,代码行数:8,代码来源:test_tbx.py


示例7: test_contents_default

def test_contents_default(tmpdir):
    """
    Test getting the contents of a file
    """
    pytest.dbgfunc()
    pt = pytest.this
    c = tbx.contents(pt['tfn'].strpath + "_nonesuch", default="take this instead")
    assert "take this instead" in c
开发者ID:tbarron,项目名称:gitr,代码行数:8,代码来源:test_tbx.py


示例8: test_contents_str

def test_contents_str(tmpdir):
    """
    Test getting the contents of a file
    """
    pytest.dbgfunc()
    pt = pytest.this
    c = tbx.contents(pt['tfn'].strpath)
    assert c == ''.join([x + '\n' for x in pt['td']])
开发者ID:tbarron,项目名称:gitr,代码行数:8,代码来源:test_tbx.py


示例9: test_contents_list

def test_contents_list(tmpdir, contents_setup):
    """
    Test getting the contents of a file
    """
    pytest.dbgfunc()
    pt = pytest.this
    c = tbx.contents(pt['tfn'].strpath, type=list)
    assert c == [x + '\n' for x in pt['td']]
开发者ID:tbarron,项目名称:gitr,代码行数:8,代码来源:test_tbx.py


示例10: test_grep

def test_grep(rgx, idx, grep_prep):
    """
    Check the results of calling U.grep()
    """
    pytest.dbgfunc()
    f = test_grep
    for n, s in enumerate(f.searches):
        assert U.grep(s, f.testdata, regex=rgx, index=idx) == f.exp[n]
开发者ID:ORNL-TechInt,项目名称:hpss-crawler,代码行数:8,代码来源:test_util.py


示例11: test_run_cmd_istr

def test_run_cmd_istr(rdata):
    """
    tbx.run(cmd, input=str)
    """
    pytest.dbgfunc()
    result = tbx.run('python', input='import this\n')
    for item in rdata.exp:
        assert item in result
开发者ID:tbarron,项目名称:tbx,代码行数:8,代码来源:test_tbx.py


示例12: test_run_cmd_istrio

def test_run_cmd_istrio(rdata):
    """
    tbx.run(cmd, input=StringIO)
    """
    pytest.dbgfunc()
    result = tbx.run('python', input=StringIO.StringIO('import this\n'))
    for item in rdata.exp:
        assert item in result
开发者ID:tbarron,项目名称:tbx,代码行数:8,代码来源:test_tbx.py


示例13: test_run_stdout

def test_run_stdout():
    """
    Run a process and capture stdout
    """
    pytest.dbgfunc()
    r = tbx.run('python -c "import this"')
    assert "Zen of Python" in r
    assert "Namespaces" in r
开发者ID:tbarron,项目名称:gitr,代码行数:8,代码来源:test_tbx.py


示例14: test_contents_good_altsep

def test_contents_good_altsep(ctest):
    """
    Calling contents on a file that exists as a list
    """
    pytest.dbgfunc()
    result = tbx.contents(ctest.data.strpath, fmt='list', sep=r'\s')
    assert len(result) == len(re.split(r'\s', ctest.exp))
    assert result == re.split(r'\s', ctest.exp)
开发者ID:tbarron,项目名称:tbx,代码行数:8,代码来源:test_tbx.py


示例15: test_run_cmd

def test_run_cmd(rdata):
    """
    With just a command (*cmd*), tbx.run() should run the command and return
    its stdout + stderr
    """
    pytest.dbgfunc()
    result = tbx.run("python -c 'import this'")
    for item in rdata.exp:
        assert item in result
开发者ID:tbarron,项目名称:tbx,代码行数:9,代码来源:test_tbx.py


示例16: test_run_noargs

def test_run_noargs():
    """
    Without arguments, tbx.run() should throw a TypeError exception
    """
    pytest.dbgfunc()
    with pytest.raises(TypeError) as err:
        tbx.run()
    assert 'run() takes' in str(err)
    assert 'argument' in str(err)
开发者ID:tbarron,项目名称:tbx,代码行数:9,代码来源:test_tbx.py


示例17: test_dispatch_help_nosuch

def test_dispatch_help_nosuch():
    """
    Dispatch help on a function that does not exist
    """
    pytest.dbgfunc()
    exp = 'Module test.test_tbx has no attribute foo_nosuch'
    with pytest.raises(SystemExit) as err:
        tbx.dispatch(__name__, 'foo', ['help', 'nosuch'])
    assert exp in str(err)
开发者ID:tbarron,项目名称:tbx,代码行数:9,代码来源:test_tbx.py


示例18: test_dispatch_help_nopfx

def test_dispatch_help_nopfx():
    """
    Dispatch help with no prefix
    """
    pytest.dbgfunc()
    exp = '*prefix* is required'
    with pytest.raises(SystemExit) as err:
        tbx.dispatch(__name__, args=['help', 'nosuch'])
    assert exp in str(err)
开发者ID:tbarron,项目名称:tbx,代码行数:9,代码来源:test_tbx.py


示例19: test_dispatch_help_nomodule

def test_dispatch_help_nomodule():
    """
    Dispatch help on a non-existent module
    """
    pytest.dbgfunc()
    exp = 'Module xtest.test_tbx is not in sys.modules'
    with pytest.raises(SystemExit) as err:
        tbx.dispatch('x' + __name__, 'foo', ['help', 'nosuch'])
    assert exp in str(err)
开发者ID:tbarron,项目名称:tbx,代码行数:9,代码来源:test_tbx.py


示例20: test_dispatch_help_nodoc

def test_dispatch_help_nodoc():
    """
    Dispatch help on a function that has no doc string
    """
    pytest.dbgfunc()
    exp = 'Function xtst_undocumented is missing a __doc__ string'
    with pytest.raises(SystemExit) as err:
        tbx.dispatch_help(__name__, 'xtst', ['undocumented'])
    assert exp in str(err)
开发者ID:tbarron,项目名称:tbx,代码行数:9,代码来源:test_tbx.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pytest.debug_func函数代码示例发布时间:2022-05-27
下一篇:
Python pytest.assert_raises函数代码示例发布时间: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