當前位置: 首頁>>代碼示例>>Python>>正文


Python bar.bar方法代碼示例

本文整理匯總了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', ) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:24,代碼來源:test_imports.py

示例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) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:20,代碼來源:test_imports.py

示例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') 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:18,代碼來源:test_imports.py

示例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) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:27,代碼來源:test_imports.py

示例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') 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:38,代碼來源:test_pdb.py

示例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
    """ 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:29,代碼來源:test_pdb.py

示例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') 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:37,代碼來源:test_pdb.py

示例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
    """ 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:29,代碼來源:test_pdb.py

示例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),
        ) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:17,代碼來源:test_pdb.py

示例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') 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:37,代碼來源:test_pdb.py

示例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) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:5,代碼來源:test_imports.py

示例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) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:7,代碼來源:test_imports.py

示例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') 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:7,代碼來源:test_imports.py

示例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') 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:7,代碼來源:test_imports.py

示例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) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:14,代碼來源:test_imports.py


注:本文中的bar.bar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。