本文整理汇总了Python中appvalidator.errorbundle.ErrorBundle.notice方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.notice方法的具体用法?Python ErrorBundle.notice怎么用?Python ErrorBundle.notice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appvalidator.errorbundle.ErrorBundle
的用法示例。
在下文中一共展示了ErrorBundle.notice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_notice
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import notice [as 别名]
def test_notice():
"""Test notice-related functions of the error bundler."""
# Use the StringIO as an output buffer.
bundle = ErrorBundle()
bundle.notice((), "")
# Load the JSON output as an object.
output = json.loads(bundle.render_json())
# Run some basic tests
assert len(output["messages"]) == 1
print output
has_ = False
for message in output["messages"]:
print message
if message["type"] == "notice":
has_ = True
assert has_
assert not bundle.failed()
assert not bundle.failed(True)
示例2: test_notice_friendly
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import notice [as 别名]
def test_notice_friendly():
"""
Test notice-related human-friendly text output functions of the error
bundler.
"""
# Use the StringIO as an output buffer.
bundle = ErrorBundle()
bundle.notice((), "foobar")
# Load the JSON output as an object.
output = bundle.print_summary(verbose=True, no_color=True)
print output
assert output.count("foobar")
示例3: test_json
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import notice [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)
示例4: test_json_constructs
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import notice [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