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


Python foo.baz方法代碼示例

本文整理匯總了Python中foo.baz方法的典型用法代碼示例。如果您正苦於以下問題:Python foo.baz方法的具體用法?Python foo.baz怎麽用?Python foo.baz使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在foo的用法示例。


在下文中一共展示了foo.baz方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_I250_from_fail_2

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_I250_from_fail_2(flake8dir):
    flake8dir.make_example_py(
        """
        from foo import bar as bar, baz as baz

        bar
        baz
    """
    )
    result = flake8dir.run_flake8()
    assert set(result.out_lines) == {
        (
            "./example.py:1:1: I250 Unnecessary import alias - rewrite as "
            + "'from foo import bar'."
        ),
        (
            "./example.py:1:1: I250 Unnecessary import alias - rewrite as "
            + "'from foo import baz'."
        ),
    }


# I251 
開發者ID:adamchainz,項目名稱:flake8-tidy-imports,代碼行數:25,代碼來源:test_flake8_tidy_imports.py

示例2: test_withStatementUndefinedInExpression

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_withStatementUndefinedInExpression(self):
        """
        An undefined name warning is emitted if a name in the I{test}
        expression of a C{with} statement is undefined.
        """
        self.flakes('''
        from __future__ import with_statement
        with bar as baz:
            pass
        ''', m.UndefinedName)

        self.flakes('''
        from __future__ import with_statement
        with bar as bar:
            pass
        ''', m.UndefinedName) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:18,代碼來源:test_other.py

示例3: test_module_attribute_as_usage

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_module_attribute_as_usage(self):
        python_node = self.get_ast_node(
            """
            import foo.bar as baz

            var = 'echo "TEST"'

            baz.qux(var)
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo.bar': ['qux']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=linter._error_tmpl
            )
        ]

        assert result == expected 
開發者ID:duo-labs,項目名稱:dlint,代碼行數:26,代碼來源:test_bad_module_attribute_use.py

示例4: test_module_attribute_import_from_as_usage

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_module_attribute_import_from_as_usage(self):
        python_node = self.get_ast_node(
            """
            from foo.bar import baz as qux

            var = 'echo "TEST"'

            qux(var)
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo.bar': ['baz']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=linter._error_tmpl
            )
        ]

        assert result == expected 
開發者ID:duo-labs,項目名稱:dlint,代碼行數:26,代碼來源:test_bad_module_attribute_use.py

示例5: test_module_attribute_missing_import_usage

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_module_attribute_missing_import_usage(self):
        python_node = self.get_ast_node(
            """
            import baz
            from qux import quine
            from . import xyz

            var = 'echo "TEST"'

            foo = None
            foo.bar(var)
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo': ['bar']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected 
開發者ID:duo-labs,項目名稱:dlint,代碼行數:23,代碼來源:test_bad_module_attribute_use.py

示例6: test_module_attribute_usage_nested

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_module_attribute_usage_nested(self):
        python_node = self.get_ast_node(
            """
            import foo

            var = 'echo "TEST"'

            foo.bar(var).baz()
            """
        )

        linter = get_bad_module_attribute_use_implementation({'foo': ['bar']})
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=linter._error_tmpl
            )
        ]

        assert result == expected 
開發者ID:duo-labs,項目名稱:dlint,代碼行數:26,代碼來源:test_bad_module_attribute_use.py

示例7: test_kwargs_present_different_module_path

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_kwargs_present_different_module_path(self):
        python_node = self.get_ast_node(
            """
            import foo
            import boo

            boo.bar.baz(kwarg="test")
            """
        )

        linter = get_bad_kwarg_use_implementation(
            [
                {
                    "module_path": "foo.bar.baz",
                    "kwarg_name": "kwarg",
                    "predicate": dlint.tree.kwarg_present,
                },
            ]
        )
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected 
開發者ID:duo-labs,項目名稱:dlint,代碼行數:27,代碼來源:test_bad_kwarg_use.py

示例8: test_kwargs_missing_module_path

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_kwargs_missing_module_path(self):
        python_node = self.get_ast_node(
            """
            import foo

            foo.bar.baz(kwarg="test")
            """
        )

        linter = get_bad_kwarg_use_implementation(
            [
                {
                    "module_path": "foo.bar.baz",
                    "kwarg_name": "kwarg",
                    "predicate": dlint.tree.kwarg_not_present,
                },
            ]
        )
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected 
開發者ID:duo-labs,項目名稱:dlint,代碼行數:26,代碼來源:test_bad_kwarg_use.py

示例9: test_it_does_not_crash_on_attribute_functions

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_it_does_not_crash_on_attribute_functions(flake8dir):
    flake8dir.make_example_py(
        """
        import foo
        bar = foo.baz(x + 1 for x in range(10))
    """
    )
    result = flake8dir.run_flake8()
    assert result.out_lines == []


# C408 
開發者ID:adamchainz,項目名稱:flake8-comprehensions,代碼行數:14,代碼來源:test_flake8_comprehensions.py

示例10: test_simple

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_simple(self):
        pkgname = 'foo'
        dirname_0 = self.create_init(pkgname)
        dirname_1 = self.create_init(pkgname)
        self.create_submodule(dirname_0, pkgname, 'bar', 0)
        self.create_submodule(dirname_1, pkgname, 'baz', 1)
        import foo.bar
        import foo.baz
        # Ensure we read the expected values
        self.assertEqual(foo.bar.value, 0)
        self.assertEqual(foo.baz.value, 1)

        # Ensure the path is set up correctly
        self.assertEqual(sorted(foo.__path__),
                         sorted([os.path.join(dirname_0, pkgname),
                                 os.path.join(dirname_1, pkgname)]))

        # Cleanup
        shutil.rmtree(dirname_0)
        shutil.rmtree(dirname_1)
        del sys.path[0]
        del sys.path[0]
        del sys.modules['foo']
        del sys.modules['foo.bar']
        del sys.modules['foo.baz']


    # Another awful testing hack to be cleaned up once the test_runpy
    # helpers are factored out to a common location 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:31,代碼來源:test_pkgutil.py

示例11: test_mixed_namespace

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_mixed_namespace(self):
        pkgname = 'foo'
        dirname_0 = self.create_init(pkgname)
        dirname_1 = self.create_init(pkgname)
        self.create_submodule(dirname_0, pkgname, 'bar', 0)
        # Turn this into a PEP 420 namespace package
        os.unlink(os.path.join(dirname_0, pkgname, '__init__.py'))
        self.create_submodule(dirname_1, pkgname, 'baz', 1)
        import foo.bar
        import foo.baz
        # Ensure we read the expected values
        self.assertEqual(foo.bar.value, 0)
        self.assertEqual(foo.baz.value, 1)

        # Ensure the path is set up correctly
        self.assertEqual(sorted(foo.__path__),
                         sorted([os.path.join(dirname_0, pkgname),
                                 os.path.join(dirname_1, pkgname)]))

        # Cleanup
        shutil.rmtree(dirname_0)
        shutil.rmtree(dirname_1)
        del sys.path[0]
        del sys.path[0]
        del sys.modules['foo']
        del sys.modules['foo.bar']
        del sys.modules['foo.baz']

    # XXX: test .pkg files 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:31,代碼來源:test_pkgutil.py

示例12: test_attrAugmentedAssignment

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_attrAugmentedAssignment(self):
        """
        Augmented assignment of attributes is supported.
        We don't care about attr refs.
        """
        self.flakes('''
        foo = None
        foo.bar += foo.baz
        ''') 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:11,代碼來源:test_other.py

示例13: test_doubleClosedOver

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_doubleClosedOver(self):
        """
        Don't warn when the assignment is used in an inner function, even if
        that inner function itself is in an inner function.
        """
        self.flakes('''
        def barMaker():
            foo = 5
            def bar():
                def baz():
                    return foo
            return bar
        ''') 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:15,代碼來源:test_other.py

示例14: test_ifexp

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_ifexp(self):
        """
        Test C{foo if bar else baz} statements.
        """
        self.flakes("a = 'moo' if True else 'oink'")
        self.flakes("a = foo if True else 'oink'", m.UndefinedName)
        self.flakes("a = 'moo' if True else bar", m.UndefinedName) 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:9,代碼來源:test_other.py

示例15: test_withStatementTupleNames

# 需要導入模塊: import foo [as 別名]
# 或者: from foo import baz [as 別名]
def test_withStatementTupleNames(self):
        """
        No warnings are emitted for using any of the tuple of names defined by
        a C{with} statement within the suite or afterwards.
        """
        self.flakes('''
        from __future__ import with_statement
        with open('foo') as (bar, baz):
            bar, baz
        bar, baz
        ''') 
開發者ID:PyCQA,項目名稱:pyflakes,代碼行數:13,代碼來源:test_other.py


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