本文整理汇总了Python中pytest.debug_func函数的典型用法代码示例。如果您正苦于以下问题:Python debug_func函数的具体用法?Python debug_func怎么用?Python debug_func使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug_func函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_newpy_overwriting_yes
def test_newpy_overwriting_yes(tmpdir):
"""
Run 'pytool newpy xyzzy' when xyzzy, xyzzy.py already exist.
Verify that confirmation is requested. Answer 'yes' and verify
that the existing file IS overwritten.
"""
pytest.debug_func()
xyzzy = toyfile(tmpdir, "xyzzy", content="original xyzzy")
xyzzy_py = toyfile(tmpdir, "xyzzy.py", content="original xyzzy.py")
with U.Chdir(tmpdir.strpath):
cmd = pexpect.which('pytool')
S = pexpect.spawn('%s newpy %s' % (cmd, xyzzy.strpath))
which = S.expect([r'Are you sure\? >',
'Error:',
pexpect.EOF])
if which == 0:
S.sendline('yes')
S.expect(pexpect.EOF)
elif which == 1:
print S.before + S.after
pytest.fail('unexpected exception')
else:
pytest.fail('should have asked about overwriting xyzzy')
exp = os.path.abspath(xyzzy_py.strpath)
got = os.readlink(xyzzy.strpath)
assert got == exp
expected = expected_xyzzy_py()
got = U.contents(xyzzy_py.strpath)
assert got == expected
示例2: test_hd_help
def test_hd_help():
"""
Verify that 'hd --help' does the right thing
"""
pytest.debug_func()
result = pexpect.run("hd --help")
assert "Hexdump stdin or a file" in result
示例3: test_docopt
def test_docopt(fx_usage):
"""
Check that pstrack.__doc__ contains what docopt requires
"""
pytest.debug_func()
for strval in fx_usage:
assert any([strval in line for line in pstrack.__doc__.split("\n")])
示例4: test_bmega
def test_bmega(fx_mchk):
"""
Test 'mag' for mebibits (1024^2)
"""
pytest.debug_func()
fx_mchk.inp, fx_mchk.exp = "98765432", "94.19 Mib"
fx_mchk.result = mag.main(["-b", fx_mchk.inp], True)
示例5: test_bgiga
def test_bgiga(fx_mchk):
"""
Test 'mag' for gibibits (1024^3)
"""
pytest.debug_func()
fx_mchk.inp, fx_mchk.exp = "12398765432", "11.55 Gib"
fx_mchk.result = mag.main(["-b", fx_mchk.inp], True)
示例6: test_bbit
def test_bbit(fx_mchk):
"""
Test 'mag' for bits (1024^0)
"""
pytest.debug_func()
fx_mchk.inp, fx_mchk.exp = "999", "999.00 b"
fx_mchk.result = mag.main([fx_mchk.inp], True)
示例7: test_bkilo
def test_bkilo(fx_mchk):
"""
Test 'mag' for kibibits (1024^1)
"""
pytest.debug_func()
fx_mchk.inp, fx_mchk.exp = "98765", "96.45 Kib"
fx_mchk.result = mag.main(["-b", fx_mchk.inp], True)
示例8: test_gtx_hooks_create_all_already
def test_gtx_hooks_create_all_already(tmpdir):
"""
Ask to create all links, some already exist
"""
pytest.debug_func()
hooklist = ['first', 'second', 'third']
bn_d = gtxtest_setup_hldirs(tmpdir.strpath,
hooks=hooklist,
mklinks=['second'])
assertLink(bn_d['second']['hook'], bn_d['second']['link'])
hookdir = bn_d['hookdir']
linkdir = bn_d['linkdir']
S = pexpect.spawn("gtx hooks -C -H %s -l %s" % (hookdir, linkdir))
while True:
which = S.expect(["does not appear to have a link",
"already has link",
pexpect.EOF,
pexpect.TIMEOUT])
if 0 == which:
S.expect(r"Shall I add one\? >")
S.sendline("y")
elif 1 == which:
pass
else:
break
assert(" <-- " in S.before)
for hook in hooklist:
assertLink(bn_d[hook]['hook'], bn_d[hook]['link'])
示例9: test_gtx_hooks_create_all_nothing
def test_gtx_hooks_create_all_nothing(tmpdir):
"""
Create all links, nothing in place
"""
pytest.debug_func()
hooklist = ['one', 'two', 'three']
hl_d = gtxtest_setup_hldirs(tmpdir.strpath, hooks=hooklist)
hookdir = hl_d['hookdir']
linkdir = hl_d['linkdir']
S = pexpect.spawn("gtx hooks -C -H %s -l %s" % (hookdir, linkdir))
while True:
which = S.expect(["does not appear to have a link",
"already has link",
pexpect.EOF,
pexpect.TIMEOUT])
if 0 == which:
S.expect(r"Shall I add one\? >")
S.sendline("y")
elif 1 == which:
pytest.fail("'already has link' was not expected")
else:
break
S.expect(pexpect.EOF)
for hook in hooklist:
hpath = os.path.join(hl_d['hookdir'], hook)
lpath = os.path.join(hl_d['linkdir'], hook)
assert(os.path.exists(hpath))
assert(os.path.exists(lpath))
示例10: test_mcal_title
def test_mcal_title():
"""
Verify that title puts out what we expect
"""
pytest.debug_func()
result = mcal.title(1999, 2)
assert result == ' 1999.02 '
示例11: test_gtx_hooks_create_name_already
def test_gtx_hooks_create_name_already(tmpdir):
"""
Create by name, some already there
"""
pytest.debug_func()
hooklist = ['one', 'two', 'three']
hl_d = gtxtest_setup_hldirs(tmpdir.strpath,
hooks=hooklist,
mklinks=['two'])
hookdir = hl_d['hookdir']
linkdir = hl_d['linkdir']
assertLink(hl_d['two']['hook'], hl_d['two']['link'])
S = pexpect.spawn("gtx hooks -C -H %s -l %s three" % (hookdir, linkdir))
while True:
which = S.expect(["does not appear to have a link",
"already has link",
pexpect.EOF,
pexpect.TIMEOUT])
if 0 == which:
S.expect(r"Shall I add one\? >")
S.sendline("y")
elif 1 == which:
pass
else:
break
S.expect(pexpect.EOF)
assertNoLink(hl_d['one']['hook'], hl_d['one']['link'])
assertLink(hl_d['two']['hook'], hl_d['two']['link'])
assertLink(hl_d['three']['hook'], hl_d['three']['link'])
示例12: test_newtool_overwriting_yes
def test_newtool_overwriting_yes(tmpdir):
"""
Run 'pytool newtool testtool tt' while testtool.py exists. Verify that
we are prompted about overwriting. Answer 'yes' and verify that the
original file is overwritten.
"""
pytest.debug_func()
tname = toyfile(tmpdir, "testtool.py", content=["original testtool.py"])
tlink = toyfile(tmpdir, "testtool", content=["original testtool"])
with U.Chdir(tmpdir.strpath):
cmd = pexpect.which("pytool")
if cmd is None:
pytest.skip("pytool not found")
S = pexpect.spawn("{} newtool {} tt".format(cmd, tlink))
which = S.expect([r'Are you sure\? >',
'Error:',
pexpect.EOF])
if which == 0:
S.sendline('yes')
S.expect(pexpect.EOF)
elif which == 1:
print S.before + S.after
pytest.fail('unexpected exception')
else:
pytest.fail("should have asked about overwriting {}".format(tname))
exp = tname.strpath
actual = tlink.readlink()
assert actual == exp
expected = expected_testtool_py()
got = tname.read().split("\n")
assert got == expected
示例13: test_newtool_overwriting_no
def test_newtool_overwriting_no(tmpdir):
"""
Run 'pytool newtool testtool tt' while testtool.py does exist. Verify
that we are prompted about overwriting. Answer 'no' and verify that the
original file is not overwritten.
"""
pytest.debug_func()
tname = toyfile(tmpdir, "testtool.py", content=["original testtool.py"])
tlink = toyfile(tmpdir, "testtool", content=["original testtool"])
with U.Chdir(tmpdir.strpath):
cmd = pexpect.which("pytool")
if cmd is None:
pytest.skip("pytool not found")
S = pexpect.spawn("{} newtool {} tt".format(cmd, tlink))
which = S.expect([r'Are you sure\? >',
'Error:',
pexpect.EOF])
if which == 0:
S.sendline('no')
S.expect(pexpect.EOF)
elif which == 1:
print S.before + S.after
pytest.fail('unexpected exception')
else:
pytest.fail("should have asked about overwriting {}".format(tname))
for fname in [tlink, tname]:
exp = "original %s" % fname.basename
got = fname.read()
assert got == exp
示例14: test_newtool
def test_newtool(tmpdir):
"""
Run 'pytool newtool testtool' while testtool.py does not exist.
Verify that testtool.py is created and has the right contents.
"""
pytest.debug_func()
toolname = toyfile(tmpdir, "testtool.py")
toollink = toyfile(tmpdir, "testtool")
with U.Chdir(tmpdir.strpath):
cmd = pexpect.which("pytool")
if cmd is None:
pytest.skip("pytool not found")
S = pexpect.spawn("{} newtool {} tt".format(cmd, toollink.strpath))
which = S.expect([r'Are you sure\? >',
'Error:',
pexpect.EOF])
if which == 0:
S.sendline('no')
S.expect(pexpect.EOF)
pytest.fail('should not have asked about overwriting')
elif which == 1:
print S.before + S.after
pytest.fail('unexpected exception')
assert toolname.strpath == toollink.readlink()
expected = expected_testtool_py()
got = toolname.read().split("\n")
assert got == expected
示例15: test_yotta
def test_yotta(fx_mchk):
"""
Test 'mag' for terabits (1000^8)
"""
pytest.debug_func()
fx_mchk.inp, fx_mchk.exp = "75843541873239090087685432", "75.84 Yb"
fx_mchk.result = mag.main([fx_mchk.inp], True)