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


Python bar.baz方法代碼示例

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


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

示例1: test_module_attribute_as_usage

# 需要導入模塊: from foo import bar [as 別名]
# 或者: from foo.bar 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

示例2: test_module_attribute_import_from_as_usage

# 需要導入模塊: from foo import bar [as 別名]
# 或者: from foo.bar 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

示例3: test_bad_parent_import_usage

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

        linter = get_bad_module_use_implementation(["foo.bar"])
        linter.visit(python_node)

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

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

示例4: test_whitelisted_import_usage

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

        linter = get_bad_module_use_implementation(
            ["foo"],
            whitelisted_modules=["foo.bar.baz"]
        )
        linter.visit(python_node)

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

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

示例5: test_whitelisted_from_import_usage

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

        linter = get_bad_module_use_implementation(
            ["foo"],
            whitelisted_modules=["foo.bar.baz"]
        )
        linter.visit(python_node)

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

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

示例6: test_relative_import_from_usage

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

        linter = get_bad_module_use_implementation(["foo"])
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

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

示例7: test_bad_import_from_as_usage

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

        linter = get_bad_module_use_implementation(["foo"])
        linter.visit(python_node)

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

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

示例8: test_kwargs_present_different_module_path

# 需要導入模塊: from foo import bar [as 別名]
# 或者: from foo.bar 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

示例9: test_kwargs_missing_module_path

# 需要導入模塊: from foo import bar [as 別名]
# 或者: from foo.bar 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

示例10: test_multiple_bad_modules_usage

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

            var = 'echo "TEST"'

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

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

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

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

示例11: test_multiple_module_depth_usage

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

            var = 'echo "TEST"'

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

        linter = get_bad_module_attribute_use_implementation(
            {'foo.bar.baz': ['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,代碼行數:28,代碼來源:test_bad_module_attribute_use.py

示例12: test_multiple_module_depth_from_usage

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

            var = 'echo "TEST"'

            bar.baz.qux(var)
            """
        )

        linter = get_bad_module_attribute_use_implementation(
            {'foo.bar.baz': ['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,代碼行數:28,代碼來源:test_bad_module_attribute_use.py

示例13: test_deeper_mismatch_import_usage

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

        linter = get_bad_module_use_implementation(["foo.bar.baz"])
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

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

示例14: test_child_mismatch_import_usage

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

        linter = get_bad_module_use_implementation(["foo.baz"])
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

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

示例15: test_child_mismatch_import_from_usage

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

        linter = get_bad_module_use_implementation(["foo.baz"])
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

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


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