本文整理匯總了Python中bar.bar方法的典型用法代碼示例。如果您正苦於以下問題:Python bar.bar方法的具體用法?Python bar.bar怎麽用?Python bar.bar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bar
的用法示例。
在下文中一共展示了bar.bar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_unusedImport_relative
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_unusedImport_relative(self):
self.flakes('from . import fu', m.UnusedImport)
self.flakes('from . import fu as baz', m.UnusedImport)
self.flakes('from .. import fu', m.UnusedImport)
self.flakes('from ... import fu', m.UnusedImport)
self.flakes('from .. import fu as baz', m.UnusedImport)
self.flakes('from .bar import fu', m.UnusedImport)
self.flakes('from ..bar import fu', m.UnusedImport)
self.flakes('from ...bar import fu', m.UnusedImport)
self.flakes('from ...bar import fu as baz', m.UnusedImport)
checker = self.flakes('from . import fu', m.UnusedImport)
error = checker.messages[0]
assert error.message == '%r imported but unused'
assert error.message_args == ('.fu', )
checker = self.flakes('from . import fu as baz', m.UnusedImport)
error = checker.messages[0]
assert error.message == '%r imported but unused'
assert error.message_args == ('.fu as baz', )
示例2: test_shadowedByForDeep
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_shadowedByForDeep(self):
"""
Test that shadowing a global name with a for loop variable nested in a
tuple unpack generates a warning.
"""
self.flakes('''
import fu
fu.bar()
for (x, y, z, (a, b, c, (fu,))) in ():
pass
''', m.ImportShadowedByLoopVar)
# Same with a list instead of a tuple
self.flakes('''
import fu
fu.bar()
for [x, y, z, (a, b, c, (fu,))] in ():
pass
''', m.ImportShadowedByLoopVar)
示例3: test_usedInOperators
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_usedInOperators(self):
self.flakes('import fu; 3 + fu.bar')
self.flakes('import fu; 3 % fu.bar')
self.flakes('import fu; 3 - fu.bar')
self.flakes('import fu; 3 * fu.bar')
self.flakes('import fu; 3 ** fu.bar')
self.flakes('import fu; 3 / fu.bar')
self.flakes('import fu; 3 // fu.bar')
self.flakes('import fu; -fu.bar')
self.flakes('import fu; ~fu.bar')
self.flakes('import fu; 1 == fu.bar')
self.flakes('import fu; 1 | fu.bar')
self.flakes('import fu; 1 & fu.bar')
self.flakes('import fu; 1 ^ fu.bar')
self.flakes('import fu; 1 >> fu.bar')
self.flakes('import fu; 1 << fu.bar')
示例4: test_usedAsClassDecorator
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_usedAsClassDecorator(self):
"""
Using an imported name as a class decorator results in no warnings,
but using an undefined name as a class decorator results in an
undefined name warning.
"""
self.flakes('''
from interior import decorate
@decorate
class foo:
pass
''')
self.flakes('''
from interior import decorate
@decorate("foo")
class bar:
pass
''')
self.flakes('''
@decorate
class foo:
pass
''', m.UndefinedName)
示例5: test_issue13183
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_issue13183(self):
script = """
from bar import bar
def foo():
bar()
def nope():
pass
def foobar():
foo()
nope()
foobar()
"""
commands = """
from bar import bar
break bar
continue
step
step
quit
"""
bar = """
def bar():
pass
"""
with open('bar.py', 'w') as f:
f.write(textwrap.dedent(bar))
self.addCleanup(test_support.unlink, 'bar.py')
self.addCleanup(test_support.unlink, 'bar.pyc')
stdout, stderr = self.run_pdb(script, commands)
self.assertTrue(
any('main.py(5)foo()->None' in l for l in stdout.splitlines()),
'Fail to step into the caller after a return')
示例6: test_pdb_displayhook
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_pdb_displayhook():
"""This tests the custom displayhook for pdb.
>>> def test_function(foo, bar):
... import pdb; pdb.Pdb().set_trace()
... pass
>>> with PdbTestInput([
... 'foo',
... 'bar',
... 'for i in range(5): write(i)',
... 'continue',
... ]):
... test_function(1, None)
> <doctest test.test_pdb.test_pdb_displayhook[0]>(3)test_function()
-> pass
(Pdb) foo
1
(Pdb) bar
(Pdb) for i in range(5): write(i)
0
1
2
3
4
(Pdb) continue
"""
示例7: test_issue13183
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_issue13183(self):
script = """
from bar import bar
def foo():
bar()
def nope():
pass
def foobar():
foo()
nope()
foobar()
"""
commands = """
from bar import bar
break bar
continue
step
step
quit
"""
bar = """
def bar():
pass
"""
with open('bar.py', 'w') as f:
f.write(textwrap.dedent(bar))
self.addCleanup(test_support.unlink, 'bar.py')
stdout, stderr = self.run_pdb(script, commands)
self.assertTrue(
any('main.py(5)foo()->None' in l for l in stdout.splitlines()),
'Fail to step into the caller after a return')
示例8: test_pdb_displayhook
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_pdb_displayhook():
"""This tests the custom displayhook for pdb.
>>> def test_function(foo, bar):
... import pdb; pdb.Pdb(nosigint=True).set_trace()
... pass
>>> with PdbTestInput([
... 'foo',
... 'bar',
... 'for i in range(5): print(i)',
... 'continue',
... ]):
... test_function(1, None)
> <doctest test.test_pdb.test_pdb_displayhook[0]>(3)test_function()
-> pass
(Pdb) foo
1
(Pdb) bar
(Pdb) for i in range(5): print(i)
0
1
2
3
4
(Pdb) continue
"""
示例9: test_find_function_found
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_find_function_found(self):
self._assert_find_function(
"""\
def foo():
pass
def bar():
pass
def quux():
pass
""",
'bar',
('bar', 4),
)
示例10: test_issue13183
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_issue13183(self):
script = """
from bar import bar
def foo():
bar()
def nope():
pass
def foobar():
foo()
nope()
foobar()
"""
commands = """
from bar import bar
break bar
continue
step
step
quit
"""
bar = """
def bar():
pass
"""
with open('bar.py', 'w') as f:
f.write(textwrap.dedent(bar))
self.addCleanup(support.unlink, 'bar.py')
stdout, stderr = self.run_pdb(script, commands)
self.assertTrue(
any('main.py(5)foo()->None' in l for l in stdout.splitlines()),
'Fail to step into the caller after a return')
示例11: test_unusedImport
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_unusedImport(self):
self.flakes('import fu, bar', m.UnusedImport, m.UnusedImport)
self.flakes('from baz import fu, bar', m.UnusedImport, m.UnusedImport)
示例12: test_aliasedImport
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_aliasedImport(self):
self.flakes('import fu as FU, bar as FU',
m.RedefinedWhileUnused, m.UnusedImport)
self.flakes('from moo import fu as FU, bar as FU',
m.RedefinedWhileUnused, m.UnusedImport)
示例13: test_aliasedImportShadowModule
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_aliasedImportShadowModule(self):
"""Imported aliases can shadow the source of the import."""
self.flakes('from moo import fu as moo; moo')
self.flakes('import fu as fu; fu')
self.flakes('import fu.bar as fu; fu')
示例14: test_usedImport_relative
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_usedImport_relative(self):
self.flakes('from . import fu; assert fu')
self.flakes('from .bar import fu; assert fu')
self.flakes('from .. import fu; assert fu')
self.flakes('from ..bar import fu as baz; assert baz')
示例15: test_redefinedInNestedFunction
# 需要導入模塊: import bar [as 別名]
# 或者: from bar import bar [as 別名]
def test_redefinedInNestedFunction(self):
"""
Test that shadowing a global name with a nested function definition
generates a warning.
"""
self.flakes('''
import fu
def bar():
def baz():
def fu():
pass
''', m.RedefinedWhileUnused, m.UnusedImport)