本文整理汇总了Python中validator.errorbundler.ErrorBundle.failed方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.failed方法的具体用法?Python ErrorBundle.failed怎么用?Python ErrorBundle.failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.errorbundler.ErrorBundle
的用法示例。
在下文中一共展示了ErrorBundle.failed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_overlay_object
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_overlay_object():
"""Test that overlay instructions have all its properties."""
err = ErrorBundle()
c = chrome_manifest("""
content namespace /foo/bar
overlay namespace /uri/goes/here
""")
err.save_resource('chrome.manifest', c)
c.get_applicable_overlays(err)
assert not err.failed()
assert not err.notices
err = ErrorBundle()
c = chrome_manifest("""
content namespace /foo/bar
overlay /uri/goes/here
""")
err.save_resource('chrome.manifest', c)
c.get_applicable_overlays(err)
assert err.failed()
assert not err.notices
示例2: _run_test_raw
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [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
示例3: test_notice
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [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)
示例4: _do_test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def _do_test(path, test, failure=True,
require_install=False, set_type=0):
package_data = open(path, "rb")
package = XPIManager(package_data, path)
contents = package.get_file_data()
err = ErrorBundle()
# Populate in the dependencies.
if set_type:
err.set_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(rdf_data)
err.save_resource("install_rdf", install_rdf)
test(err, contents, package)
print err.print_summary(verbose=True)
if failure:
assert err.failed()
else:
assert not err.failed()
return err
示例5: _do_test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [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_results_aggregator
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_results_aggregator():
'Tests that language pack aggregation results are read properly.'
err = ErrorBundle()
l10n._aggregate_results(err,
[{'type':'missing_files',
'filename':'foo.bar'}],
{'name': 'en-US',
'target': 'foo.bar',
'jarred': False})
assert err.failed()
err = ErrorBundle()
l10n._aggregate_results(err,
[{'type':'missing_entities',
'filename':'foo.bar',
'missing_entities':['asdf','ghjk']}],
{'name': 'en-US',
'target': 'foo.bar',
'jarred': False})
assert err.failed()
err = ErrorBundle()
l10n._aggregate_results(err,
[{'type':'unchanged_entity',
'entities':0,
'unchanged_entities':[('asdf', 1), ('ghjk', 1)],
'filename':'foo.bar'},
{'type':'total_entities',
'entities':100}],
{'name': 'en-US',
'target': 'foo.bar',
'jarred': False})
assert not err.failed()
err = ErrorBundle()
l10n._aggregate_results(err,
[{'type':'unchanged_entity',
'entities':50,
'unchanged_entities':[('asdf', 1), ('ghjk', 1)],
'filename':'foo.bar'},
{'type':'file_entity_count',
'filename':'foo.bar',
'entities':100},
{'type':'total_entities',
'entities':100}],
{'name': 'en-US',
'target': 'foo.bar',
'path': '/locale/en-US/',
'jarred': True})
assert not err.failed()
assert err.notices
print err.notices
assert all('//' not in ''.join(m['file']) for m in err.warnings)
示例7: test_valid_chrome_manifest
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_valid_chrome_manifest():
'Chrome manifests must only contain certain elements'
err = ErrorBundle()
err.save_resource('chrome.manifest', chrome_manifest('locale foo bar'))
langpack.test_langpack_manifest(err, MockXPI())
assert not err.failed()
err.save_resource('chrome.manifest', chrome_manifest('foo bar asdf'))
langpack.test_langpack_manifest(err, MockXPI())
assert err.failed()
示例8: _test_value
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def _test_value(value, test, failure=True):
"Tests a value against a test."
err = ErrorBundle()
test(err, value)
if failure:
return err.failed()
else:
return not err.failed()
示例9: _do_test
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def _do_test(url, failure=True, listed=False):
err = ErrorBundle()
results = detect_opensearch(err, open(url), listed=listed)
if results.failed():
print results.print_summary()
if failure:
assert err.failed()
else:
assert not err.failed()
示例10: test_valid_chrome_manifest
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_valid_chrome_manifest():
"Chrome manifests must only contain certain elements"
err = ErrorBundle()
err.save_resource("chrome.manifest", ChromeManifest("locale foo bar", ""))
langpack.test_langpack_manifest(err, MockXPI())
assert not err.failed()
err.save_resource("chrome.manifest", ChromeManifest("foo bar asdf", ""))
langpack.test_langpack_manifest(err, MockXPI())
assert err.failed()
示例11: test_no_chromemanifest
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_no_chromemanifest():
"""
Chrome manifest tests should not be run if there is no chrome manifest.
"""
err = ErrorBundle()
assert tc_chromemanifest.test_categories(err) is None
assert not err.failed()
err = ErrorBundle()
assert tc_chromemanifest.test_resourcemodules(err) is None
assert not err.failed()
示例12: test_scripting_snippet
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_scripting_snippet():
'Assert that JS snippets are treated equally.'
err = ErrorBundle()
err.supported_versions = {}
scripting.test_js_snippet(err, 'alert(1 + 1 == 2)', 'bar.zap')
assert not err.failed()
err = ErrorBundle()
err.supported_versions = {}
scripting.test_js_snippet(err, "eval('foo');", 'bar.zap')
assert err.failed()
示例13: test_webapp_installs_allowed_from_missing_listed
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_webapp_installs_allowed_from_missing_listed():
"""Test that installs_allowed_from is present when listed.."""
err = ErrorBundle(listed=False)
data = _get_json()
del data["installs_allowed_from"]
_detect(err, data)
assert not err.failed()
err = ErrorBundle(listed=True)
_detect(err, data)
assert err.failed()
示例14: test_scripting_snippet
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_scripting_snippet():
"Asserts that JS snippets are treated equally"
err = ErrorBundle()
err.supported_versions = {}
scripting.test_js_snippet(err, "alert(1 + 1 == 2)", "bar.zap")
assert not err.failed()
err = ErrorBundle()
err.supported_versions = {}
scripting.test_js_snippet(err, "eval('foo');", "bar.zap")
assert err.failed()
示例15: test_prepare_package_xml
# 需要导入模块: from validator.errorbundler import ErrorBundle [as 别名]
# 或者: from validator.errorbundler.ErrorBundle import failed [as 别名]
def test_prepare_package_xml(test_search):
'Tests that the prepare_package function passes with search providers'
err = ErrorBundle()
submain.prepare_package(err, 'tests/resources/main/foo.xml')
assert not err.failed()
assert test_search.called
test_search.side_effect = lambda err, *args: err.error(('x'), 'Failed')
submain.prepare_package(err, 'tests/resources/main/foo.xml')
assert err.failed()