本文整理汇总了Python中validator.errorbundler.ErrorBundle.push_state方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.push_state方法的具体用法?Python ErrorBundle.push_state怎么用?Python ErrorBundle.push_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.errorbundler.ErrorBundle
的用法示例。
在下文中一共展示了ErrorBundle.push_state方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pushable_resources
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_pushable_resources():
"""
Test that normal resources are preserved but pushable ones are pushed.
"""
e = ErrorBundle()
e.save_resource("nopush", True)
e.save_resource("push", True, pushable=True)
assert e.get_resource("nopush")
assert e.get_resource("push")
e.push_state()
assert e.get_resource("nopush")
assert not e.get_resource("push")
e.save_resource("pushed", True, pushable=True)
assert e.get_resource("pushed")
e.pop_state()
assert e.get_resource("nopush")
assert e.get_resource("push")
assert not e.get_resource("pushed")
示例2: test_subpackage
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_subpackage():
"Test a package with localization that should pass validation."
err = ErrorBundle()
err.set_type(PACKAGE_DICTIONARY)
assert l10n.test_xpi(err, None) is None
err.set_type(PACKAGE_EXTENSION)
err.push_state()
assert l10n.test_xpi(err, None) is None
示例3: test_subpackage
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_subpackage():
'Test a package with localization that should pass validation.'
err = ErrorBundle()
err.detected_type = PACKAGE_DICTIONARY
assert l10n.test_xpi(err, None) is None
err.detected_type = PACKAGE_EXTENSION
err.push_state()
assert l10n.test_xpi(err, None) is None
示例4: test_unsigned_inner_xpi
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_unsigned_inner_xpi():
"""Test that inner XPIs need to be signed even if not multi-package."""
xpi = MockXPI(subpackage=True)
err = ErrorBundle()
err.supported_versions = {}
err.push_state('inner.xpi')
err.save_resource('is_multipackage', False)
content.test_signed_xpi(err, xpi)
assert err.failed()
示例5: test_unsigned_inner_jar
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_unsigned_inner_jar():
"""Test that inner packages don't need to be signed if not multipackage."""
xpi = MockXPI(subpackage=True)
xpi.filename = 'mock_jar.jar'
err = ErrorBundle()
err.supported_versions = {}
err.push_state('inner.jar')
err.save_resource('is_multipackage', False)
content.test_signed_xpi(err, xpi)
assert not err.failed()
示例6: test_unsigned_multi_xpi
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_unsigned_multi_xpi():
"""Test that unsigned inner packages raise an error."""
xpi = MockXPI(subpackage=True)
err = ErrorBundle()
err.supported_versions = {}
err.push_state('sub.xpi')
err.save_resource('is_multipackage', True)
content.test_signed_xpi(err, xpi)
assert err.failed()
assert not err.warnings
assert err.errors
assert err.errors[0]['id'] == ('testcases_content', 'unsigned_sub_xpi')
示例7: test_mozilla_signed_multi_xpi
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_mozilla_signed_multi_xpi():
"""Test that mozilla signed inner packages don't raise an error."""
xpi = MockXPI({
'META-INF/manifest.mf': 'tests/resources/main/foo.bar',
'META-INF/mozilla.rsa': 'tests/resources/main/foo.bar',
'META-INF/mozilla.sf': 'tests/resources/main/foo.bar',
}, subpackage=True)
err = ErrorBundle()
err.supported_versions = {}
err.push_state('sub.xpi')
err.save_resource('is_multipackage', True)
content.test_signed_xpi(err, xpi)
assert not err.failed()
示例8: test_other_signed_multi_xpi
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_other_signed_multi_xpi():
"""Test that other signed inner packages raise an error."""
xpi = MockXPI({
'META-INF/manifest.mf': 'tests/resources/main/foo.bar',
'META-INF/zigbert.rsa': 'tests/resources/main/foo.bar',
'META-INF/zigbert.sf': 'tests/resources/main/foo.bar',
}, subpackage=True)
err = ErrorBundle()
err.supported_versions = {}
err.push_state('sub.xpi')
err.save_resource('is_multipackage', True)
content.test_signed_xpi(err, xpi)
assert err.failed()
assert not err.warnings
assert err.errors
assert err.errors[0]['id'] == ('testcases_content', 'unsigned_sub_xpi')
示例9: test_states
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_states():
"""Test that detected type is preserved, even in subpackages."""
# Use the StringIO as an output buffer.
bundle = ErrorBundle()
# Populate the bundle with some test data.
bundle.detected_type = 4
bundle.error((), "error")
bundle.warning((), "warning")
bundle.notice((), "notice")
bundle.save_resource("test", True)
# Push a state
bundle.push_state("test.xpi")
bundle.detected_type = 2
bundle.error((), "nested error")
bundle.warning((), "nested warning")
bundle.notice((), "nested notice")
# Push another state
bundle.push_state("test2.xpi")
bundle.detected_type = 3
bundle.error((), "super nested error")
bundle.warning((), "super nested warning")
bundle.notice((), "super nested notice")
# Test that nested compatibility messages retain various # properties.
bundle.notice("comp", "Compat Test notice", compatibility_type="error", editors_only=True, signing_severity="high")
bundle.pop_state()
bundle.pop_state()
# Load the JSON output as an object.
output = json.loads(bundle.render_json())
# Run some basic tests
assert output["detected_type"] == "langpack"
assert len(output["messages"]) == 10
messages = [
"error",
"warning",
"notice",
"nested error",
"nested warning",
"nested notice",
"super nested error",
"super nested warning",
"super nested notice",
"Compat Test notice",
]
for message in output["messages"]:
assert message["message"] in messages
messages.remove(message["message"])
assert message["message"].endswith(message["type"])
if message["id"] == "comp":
assert message["compatibility_type"] == "error"
assert message["editors_only"] == True
assert message["signing_severity"] == "high"
assert not messages
assert bundle.get_resource("test")
示例10: test_file_structure
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [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(determined=True)
# Populate the bundle with some test data.
bundle.error((), "error", description="", filename="file1", column=123)
bundle.error((), "error", description="", filename="file2")
bundle.error((), "error")
# Push a state
bundle.push_state("foo")
bundle.warning((), "warning", description="", filename="file4", column=123)
bundle.warning((), "warning", description="", filename="file5")
bundle.warning((), "warning")
bundle.pop_state()
# 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
assert len(output["messages"]) == 6
assert len(output2) < len(output3)
print output
print "*" * 50
print output2
print "*" * 50
print output3
print "*" * 50
messages = ["file1", "file2", "", ["foo", "file4"], ["foo", "file5"], ["foo", ""]]
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
示例11: test_states
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_states():
"""Test that detected type is preserved, even in subpackages."""
# Use the StringIO as an output buffer.
bundle = ErrorBundle()
# Populate the bundle with some test data.
bundle.detected_type = 4
bundle.error((), 'error')
bundle.warning((), 'warning')
bundle.notice((), 'notice')
bundle.save_resource('test', True)
# Push a state
bundle.push_state('test.xpi')
bundle.detected_type = 2
bundle.error((), 'nested error')
bundle.warning((), 'nested warning')
bundle.notice((), 'nested notice')
# Push another state
bundle.push_state('test2.xpi')
bundle.detected_type = 3
bundle.error((), 'super nested error')
bundle.warning((), 'super nested warning')
bundle.notice((), 'super nested notice')
# Test that nested compatibility messages retain various # properties.
bundle.notice('comp', 'Compat Test notice',
compatibility_type='error',
editors_only=True,
signing_severity='high')
bundle.pop_state()
bundle.pop_state()
# Load the JSON output as an object.
output = json.loads(bundle.render_json())
# Run some basic tests
assert output['detected_type'] == 'langpack'
assert len(output['messages']) == 10
messages = ['error',
'warning',
'notice',
'nested error',
'nested warning',
'nested notice',
'super nested error',
'super nested warning',
'super nested notice',
'Compat Test notice']
for message in output['messages']:
assert message['message'] in messages
messages.remove(message['message'])
assert message['message'].endswith(message['type'])
if message['id'] == 'comp':
assert message['compatibility_type'] == 'error'
assert message['editors_only'] is True
assert message['signing_severity'] == 'high'
assert not messages
assert bundle.get_resource('test')
示例12: test_file_structure
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [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(True) # No color since no output
# Populate the bundle with some test data.
bundle.error((), 'error', description='',
filename='file1', column=123)
bundle.error((), 'error', description='',
filename='file2')
bundle.error((), 'error')
# Push a state
bundle.push_state('foo')
bundle.warning((), 'warning', description='',
filename='file4', column=123)
bundle.warning((), 'warning', description='',
filename='file5')
bundle.warning((), 'warning')
bundle.pop_state()
# 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
assert len(output['messages']) == 6
assert len(output2) < len(output3)
print output
print '*' * 50
print output2
print '*' * 50
print output3
print '*' * 50
messages = ['file1', 'file2', '',
['foo', 'file4'], ['foo', 'file5'], ['foo', '']]
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
示例13: test_states
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import push_state [as 别名]
def test_states():
"""Tests that detected type is preserved, even in subpackages."""
# Use the StringIO as an output buffer.
bundle = ErrorBundle()
# Populate the bundle with some test data.
bundle.set_type(4)
bundle.error((), "error")
bundle.warning((), "warning")
bundle.notice((), "notice")
bundle.save_resource("test", True)
# Push a state
bundle.push_state("test.xpi")
bundle.set_type(2)
bundle.error((), "nested error")
bundle.warning((), "nested warning")
bundle.notice((), "nested notice")
# Push another state
bundle.push_state("test2.xpi")
bundle.set_type(3)
bundle.error((), "super nested error")
bundle.warning((), "super nested warning")
bundle.notice((), "super nested notice")
bundle.pop_state()
bundle.pop_state()
# Load the JSON output as an object.
output = json.loads(bundle.render_json())
# Run some basic tests
assert output["detected_type"] == "langpack"
assert len(output["messages"]) == 9
print output
messages = ["error",
"warning",
"notice",
"nested error",
"nested warning",
"nested notice",
"super nested error",
"super nested warning",
"super nested notice"]
for message in output["messages"]:
print message
assert message["message"] in messages
messages.remove(message["message"])
assert message["message"].endswith(message["type"])
assert not messages
assert bundle.get_resource("test")