本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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