本文整理汇总了Python中pytest.dbgfunc函数的典型用法代码示例。如果您正苦于以下问题:Python dbgfunc函数的具体用法?Python dbgfunc怎么用?Python dbgfunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbgfunc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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')
示例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)
示例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
示例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)
示例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)
示例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
示例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']])
示例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']]
示例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]
示例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
示例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
示例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
示例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)
示例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