当前位置: 首页>>代码示例>>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;未经允许,请勿转载。