本文整理汇总了Python中validator.errorbundler.ErrorBundle.detected_type方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.detected_type方法的具体用法?Python ErrorBundle.detected_type怎么用?Python ErrorBundle.detected_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.errorbundler.ErrorBundle
的用法示例。
在下文中一共展示了ErrorBundle.detected_type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subpackage
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [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
示例2: test_invalid_package_type
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_invalid_package_type():
"No such thing as a Conduit theme."
err = ErrorBundle(None, True)
err.detected_type = PACKAGE_ANY
assert conduit.test_conduittoolbar(err) is None
err.detected_type = PACKAGE_THEME
assert conduit.test_conduittoolbar(err) is None
err.detected_type = PACKAGE_SEARCHPROV
assert conduit.test_conduittoolbar(err) is None
示例3: test_invalid_package_type
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_invalid_package_type():
"""Assert that conduit toolbars can only be extensions."""
err = ErrorBundle()
err.detected_type = PACKAGE_ANY
assert conduit.test_conduittoolbar(err) is None
err.detected_type = PACKAGE_THEME
assert conduit.test_conduittoolbar(err) is None
err.detected_type = PACKAGE_SEARCHPROV
assert conduit.test_conduittoolbar(err) is None
示例4: _run_test_raw
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def _run_test_raw(data, failure=True, detected_type=0, listed=True,
overrides=None, compat=False):
"Runs a test on an install.rdf snippet"
data = data.strip()
err = ErrorBundle()
err.detected_type = detected_type
err.save_resource("listed", listed)
err.overrides = overrides
if compat:
err.save_resource("is_compat_test", True)
err.save_resource("has_install_rdf", True)
err.save_resource("install_rdf", RDFParser(err, data))
installrdf.test_install_rdf_params(err)
print err.print_summary(verbose=True)
if failure: # pragma: no cover
assert err.failed() or err.notices
else:
assert not err.failed() and not err.notices
return err
示例5: _do_test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def _do_test(path, test, failure=True,
require_install=False, set_type=0,
listed=False, xpi_mode="r"):
package_data = open(path, "rb")
package = XPIManager(package_data, mode=xpi_mode, name=path)
err = ErrorBundle()
if listed:
err.save_resource("listed", True)
# Populate in the dependencies.
if set_type:
err.detected_type = set_type # Conduit test requires type
if require_install:
err.save_resource("has_install_rdf", True)
rdf_data = package.read("install.rdf")
install_rdf = RDFParser(err, rdf_data)
err.save_resource("install_rdf", install_rdf)
populate_chrome_manifest(err, package)
test(err, package)
print err.print_summary(verbose=True)
if failure:
assert err.failed()
else:
assert not err.failed()
return err
示例6: test_webapp_bom
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_webapp_bom():
"""Test that a plain webapp with a BOM won't throw errors."""
err = ErrorBundle(listed=False)
err.detected_type = validator.constants.PACKAGE_WEBAPP
validator.webapp.detect_webapp(
err, "tests/resources/unicodehelper/utf8_webapp.json")
assert not err.failed()
示例7: test_type
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_type():
"""
Test that detected type is being stored properly in the error bundle.
"""
bundle = ErrorBundle()
bundle.detected_type = 5
assert bundle.detected_type == 5
示例8: test_subpackage_metadata_preserved
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_subpackage_metadata_preserved():
"""Tests that metadata is preserved for sub-packages."""
xpi1 = open('tests/resources/jetpack/jetpack-1.16-outdated.xpi')
xpi2 = MockXPI({
'thing.xpi': 'tests/resources/jetpack/jetpack-1.16-outdated.xpi'})
err1 = ErrorBundle()
err1.detected_type = PACKAGE_EXTENSION
err2 = ErrorBundle()
err2.detected_type = PACKAGE_EXTENSION
submain.test_package(err1, xpi1, 'jetpack-1.16-outdated.xpi')
content.test_packed_packages(err2, xpi2)
assert 'sub_packages' in err2.metadata
assert err1.metadata == err2.metadata['sub_packages'].get('thing.xpi')
示例9: test_subpackage_metadata_preserved
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_subpackage_metadata_preserved():
"""Tests that metadata is preserved for sub-packages."""
xpi1 = open("tests/resources/jetpack/jetpack-1.8-outdated.xpi")
xpi2 = MockXPI({
"thing.xpi": "tests/resources/jetpack/jetpack-1.8-outdated.xpi"})
err1 = ErrorBundle()
err1.detected_type = PACKAGE_EXTENSION
err2 = ErrorBundle()
err2.detected_type = PACKAGE_EXTENSION
submain.test_package(err1, xpi1, "jetpack-1.8-outdated.xpi")
content.test_packed_packages(err2, xpi2)
assert "sub_packages" in err2.metadata
eq_(err1.metadata, err2.metadata["sub_packages"]
.get("thing.xpi"))
示例10: test_json_constructs
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_json_constructs():
"""This tests some of the internal JSON stuff so we don't break zamboni."""
e = ErrorBundle()
e.detected_type = 1
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=("x", "y", "z"))
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 "detected_type" in j
assert j["detected_type"] == "extension"
assert "message_tree" in j
tree = j["message_tree"]
assert "__errors" not in tree
assert not tree["a"]["__messages"]
assert tree["a"]["__errors"] == 4
assert not tree["a"]["b"]["__messages"]
assert tree["a"]["b"]["__errors"] == 2
assert not tree["a"]["b"]["__messages"]
assert tree["a"]["b"]["c"]["__errors"] == 1
assert tree["a"]["b"]["c"]["__messages"]
assert "messages" in j
for m in (m 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
示例11: test_langpack
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_langpack():
'Tests a language pack in the content validator.'
err = ErrorBundle()
err.supported_versions = {}
err.detected_type = PACKAGE_LANGPACK
mock_package = MockXPI({'foo.dtd': 'tests/resources/content/junk.xpi'})
content.test_packed_packages(err, mock_package)
content.testendpoint_langpack.assert_expectation('test_unsafe_html', 1)
content.testendpoint_langpack.assert_expectation('test_unsafe_html', 0,
'subpackage')
示例12: test_has_rdf
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_has_rdf(install_rdf):
"Tests that tests won't be run if there's no install.rdf"
err = ErrorBundle()
assert installrdf.test_install_rdf_params(err, None) is None
err.detected_type = 0
err.save_resource("install_rdf", RDFParser(err, "<rdf></rdf>"))
err.save_resource("has_install_rdf", True)
installrdf.test_install_rdf_params(err, None)
assert install_rdf.called
示例13: test_langpack
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def test_langpack():
"Tests a language pack in the content validator."
err = ErrorBundle()
err.supported_versions = {}
err.detected_type = PACKAGE_LANGPACK
mock_package = MockXPI({"foo.dtd": "tests/resources/content/junk.xpi"})
result = content.test_packed_packages(err, 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: _do_test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def _do_test(unpack=False, contents=None, set_type=0, is_ff4=False):
'Runs the tests. Handy as hell.'
if not contents:
contents = []
err = ErrorBundle(None, True)
if set_type:
err.detected_type = set_type
err.save_resource('em:unpack', unpack)
err.save_resource('ff4', is_ff4)
packagelayout.test_emunpack(
err, MockXPI(dict(zip(contents, [True for c in contents]))))
return err
示例15: _do_real_test_raw
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import detected_type [as 别名]
def _do_real_test_raw(script, path="foo.js", versions=None, detected_type=None,
metadata=None, resources=None):
"""Perform a JS test using a non-mock bundler."""
err = ErrorBundle()
if detected_type:
err.detected_type = detected_type
err.supported_versions = versions or {}
if metadata is not None:
err.metadata = metadata
if resources is not None:
err.resources = resources
validator.testcases.content._process_file(err, MockXPI(), path, script)
return err