本文整理汇总了Python中validator.errorbundler.ErrorBundle类的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle类的具体用法?Python ErrorBundle怎么用?Python ErrorBundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorBundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_jar_nonsubpackage
def test_jar_nonsubpackage():
"Tests XPI files that are not subpackages."
err = ErrorBundle()
err.set_type(PACKAGE_MULTI)
err.save_resource("is_multipackage", True)
mock_package = MockXPI(
{"foo.jar":
"tests/resources/content/subpackage.jar",
"chrome/bar.jar":
"tests/resources/content/subpackage.jar"})
content.testendpoint_validator = MockTestEndpoint(("test_inner_package",
"test_package"))
result = content.test_packed_packages(
err,
mock_package)
print result
assert result == 2
content.testendpoint_validator.assert_expectation(
"test_package",
2)
content.testendpoint_validator.assert_expectation(
"test_package",
0,
"subpackage")
示例2: test_jar_subpackage
def test_jar_subpackage():
"Tests JAR files that are subpackages."
err = ErrorBundle()
err.set_type(PACKAGE_EXTENSION)
err.supported_versions = {"foo": ["1.2.3"]}
mock_package = MockXPI(
{"chrome/subpackage.jar":
"tests/resources/content/subpackage.jar",
"subpackage.jar":
"tests/resources/content/subpackage.jar"})
content.testendpoint_validator = \
MockTestEndpoint(("test_inner_package", ))
result = content.test_packed_packages(
err,
mock_package)
print result
assert result == 2
content.testendpoint_validator.assert_expectation(
"test_inner_package",
2)
content.testendpoint_validator.assert_expectation(
"test_inner_package",
2,
"subpackage")
assert err.supported_versions == {"foo": ["1.2.3"]}
示例3: test_prepare_package_missing
def test_prepare_package_missing():
'Tests that the prepare_package function fails when file is not found'
err = ErrorBundle()
submain.prepare_package(err, 'foo/bar/asdf/qwerty.xyz')
assert err.failed()
示例4: test_prepare_package_bad_file
def test_prepare_package_bad_file():
'Tests that the prepare_package function fails for unknown files'
err = ErrorBundle()
submain.prepare_package(err, 'tests/resources/main/foo.bar')
assert err.failed()
示例5: _test
def _test(script):
err = ErrorBundle()
err.supported_versions = {}
err.save_resource("em:bootstrap", "true")
scripting.test_js_file(err, "foo", script)
return err
示例6: test_prepare_package
def test_prepare_package(test_package):
"""Tests that the prepare_package does not raise any errors when given
a valid add-on."""
err = ErrorBundle()
submain.prepare_package(err, 'tests/resources/main/foo.xpi')
assert not err.failed()
示例7: test_structure
def test_structure(structure):
err = ErrorBundle()
err.supported_versions = {}
mock_package = MockXPI(structure)
content.test_packed_packages(err, mock_package)
print err.print_summary(verbose=True)
assert err.failed()
示例8: test_version_forappversions_accepted
def test_version_forappversions_accepted():
"""
Test that for_appversions targets application versions properly.
"""
err = ErrorBundle()
err.supported_versions = {'firefox': ['1.2.3']}
tests = decorator.TEST_TIERS
decorator.TEST_TIERS = {}
@decorator.register_test(tier=5, versions={'firefox': ['1.0.0',
'1.2.3']})
def version_test(err, xpi):
print 'Ran test'
err.save_resource('executed', True)
print decorator.TEST_TIERS
validator.submain.test_inner_package(err, MockXPI(),
for_appversions={'firefox':
['1.2.3']})
assert err.get_resource('executed')
decorator.TEST_TIERS = tests
示例9: _do_test
def _do_test(xpi_package, allow_old_sdk=True, compat=False):
err = ErrorBundle()
if compat:
err.save_resource('is_compat_test', True)
jetpack.inspect_jetpack(err, xpi_package, allow_old_sdk=allow_old_sdk)
return err
示例10: test_notice
def test_notice():
"""Tests 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()
示例11: setup_err
def setup_err(package_json=None, err=None):
if err is None:
err = ErrorBundle()
if package_json is not None:
err.save_resource("has_package_json", True)
err.save_resource("package_json", package_json)
return err
示例12: setup_err
def setup_err(manifest_json=None, err=None):
if err is None:
err = ErrorBundle()
if manifest_json is not None:
err.save_resource('has_manifest_json', True)
err.save_resource('manifest_json', manifest_json)
return err
示例13: test_langpack
def test_langpack():
"Tests a language pack in the content validator."
err = ErrorBundle(None, True)
err.set_type(PACKAGE_LANGPACK)
mock_package = MockXPIManager(
{"foo.dtd":
"tests/resources/content/junk.xpi"})
content.testendpoint_langpack = \
MockTestEndpoint(("test_unsafe_html", ))
result = content.test_packed_packages(
err,
{"foo.dtd":
{"extension": "dtd",
"name_lower": "foo.dtd"}},
mock_package)
print result
assert result == 1
content.testendpoint_langpack.assert_expectation(
"test_unsafe_html",
1)
content.testendpoint_langpack.assert_expectation(
"test_unsafe_html",
0,
"subpackage")
示例14: test_proper_linked_manifest_relative
def test_proper_linked_manifest_relative():
"""
Test that linked manifests are imported relatively when using relative
paths.
"""
err = ErrorBundle()
package = MockXPI(
{
"chrome.manifest": "tests/resources/submain/linkman/subdir.manifest",
"dir/level2.manifest": "tests/resources/submain/linkman/foosub.manifest",
"dir/foo.manifest": "tests/resources/submain/linkman/base2.manifest",
}
)
submain.populate_chrome_manifest(err, package)
chrome = err.get_resource("chrome.manifest")
assert chrome
assert not err.failed() or err.notices
# From the linked manifest:
zaps = list(chrome.get_entries("zap"))
assert zaps
eq_(zaps[0]["filename"], "dir/foo.manifest")
eq_(zaps[0]["context"].data, ["zap baz", ""])
示例15: test_xpi_subpackage
def test_xpi_subpackage():
"XPIs should never be subpackages; only nested extensions"
err = ErrorBundle()
err.set_type(PACKAGE_EXTENSION)
mock_package = MockXPI(
{"chrome/package.xpi":
"tests/resources/content/subpackage.jar"})
content.testendpoint_validator = \
MockTestEndpoint(("test_package", ))
result = content.test_packed_packages(
err,
mock_package)
print result
assert result == 1
content.testendpoint_validator.assert_expectation(
"test_package",
1)
content.testendpoint_validator.assert_expectation(
"test_package",
0,
"subpackage")