本文整理汇总了Python中appvalidator.errorbundle.ErrorBundle.warning方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.warning方法的具体用法?Python ErrorBundle.warning怎么用?Python ErrorBundle.warning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appvalidator.errorbundle.ErrorBundle
的用法示例。
在下文中一共展示了ErrorBundle.warning方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_json
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import warning [as 别名]
def test_json():
"""Test the JSON output capability of the error bundler."""
# Use the StringIO as an output buffer.
bundle = ErrorBundle() # No color since no output
bundle.set_tier(4)
bundle.set_tier(3)
bundle.error((), "error", "description")
bundle.warning((), "warning", "description")
bundle.notice((), "notice", "description")
results = json.loads(bundle.render_json())
eq_(len(results["messages"]), 3)
assert not results["success"]
eq_(results["ending_tier"], 4)
示例2: test_json_constructs
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import warning [as 别名]
def test_json_constructs():
"""This tests some of the internal JSON stuff so we don't break zamboni."""
e = ErrorBundle()
e.error(("a", "b", "c"), "Test")
e.error(("a", "b", "foo"), "Test")
e.error(("a", "foo", "c"), "Test")
e.error(("a", "foo", "c"), "Test")
e.error(("b", "foo", "bar"), "Test")
e.warning((), "Context test",
context=ContextGenerator("x\ny\nz\n"),
line=2, column=0)
e.notice((), "none")
e.notice((), "line", line=1)
e.notice((), "column", column=0)
e.notice((), "line column", line=1, column=1)
results = e.render_json()
print results
j = json.loads(results)
assert "messages" in j
for m in j["messages"]:
if m["type"] == "warning":
assert m["context"] == ["x", "y", "z"]
for m in (m for m in j["messages"] if m["type"] == "notice"):
if "line" in m["message"]:
assert m["line"] is not None
assert isinstance(m["line"], int)
assert m["line"] > 0
else:
assert m["line"] is None
if "column" in m["message"]:
assert m["column"] is not None
assert isinstance(m["column"], int)
assert m["column"] > -1
else:
assert m["column"] is None
示例3: test_file_structure
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import warning [as 别名]
def test_file_structure():
"""
Test the means by which file names and line numbers are stored in errors,
warnings, and messages.
"""
# Use the StringIO as an output buffer.
bundle = ErrorBundle()
# Populate the bundle with some test data.
bundle.error((), "error", "", "file1", 123)
bundle.error((), "error", "", "file2")
bundle.warning((), "warning", "", "file4", 123)
bundle.warning((), "warning", "", "file5")
bundle.warning((), "warning")
# Load the JSON output as an object.
output = json.loads(bundle.render_json())
# Do the same for friendly output
output2 = bundle.print_summary(verbose=False)
# Do the same for verbose friendly output
output3 = bundle.print_summary(verbose=True)
# Run some basic tests
eq_(len(output["messages"]), 5)
assert len(output2) < len(output3)
messages = ["file1", "file2", "", "file4", "file5"]
for message in output["messages"]:
print message
assert message["file"] in messages
messages.remove(message["file"])
if isinstance(message["file"], list):
pattern = message["file"][:]
pattern.pop()
pattern.append("")
file_merge = " > ".join(pattern)
print file_merge
assert output3.count(file_merge)
else:
assert output3.count(message["file"])
assert not messages