本文整理汇总了Python中appvalidator.errorbundle.ErrorBundle.failed方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle.failed方法的具体用法?Python ErrorBundle.failed怎么用?Python ErrorBundle.failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appvalidator.errorbundle.ErrorBundle
的用法示例。
在下文中一共展示了ErrorBundle.failed方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_notice
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.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)
示例2: _do_test
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def _do_test(path, should_fail=False):
data = open(path).read()
err = ErrorBundle()
csstester.test_css_file(err, "css.css", data)
err.print_summary(True)
if should_fail:
assert err.failed()
else:
assert not err.failed()
return err
示例3: test_prepare_package_webapp
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def test_prepare_package_webapp(fake_webapp_validator):
err = ErrorBundle()
package = "tests/resources/main/mozball.webapp"
submain.prepare_package(err, package)
assert not err.failed()
fake_webapp_validator.assert_called_with(err, package)
示例4: test_prepare_package_bad_file
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
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_prepare_package_missing
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
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()
示例6: test_version_control
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def test_version_control():
"""Test that version control in a package are caught."""
package = MockXPI({".git/foo/bar": None})
err = ErrorBundle()
packagelayout.test_blacklisted_files(err, package)
assert err.failed()
示例7: _do_test
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def _do_test(path, test, failure=True, set_type=0,
listed=False, xpi_mode="r"):
package_data = open(path, "rb")
package = ZipPackage(package_data, mode=xpi_mode, name=path)
err = ErrorBundle()
if listed:
err.save_resource("listed", True)
# Populate in the dependencies.
if set_type:
err.set_type(set_type) # Conduit test requires type
test(err, package)
print err.print_summary(verbose=True)
assert err.failed() if failure else not err.failed()
return err
示例8: test_duplicate_files
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def test_duplicate_files():
"""Test that duplicate files in a package are caught."""
package = MagicMock()
package.zf = zf = MagicMock()
zf.namelist.return_value = ["foo.bar", "foo.bar"]
err = ErrorBundle()
packagelayout.test_layout_all(err, package)
assert err.failed()
示例9: test_spaces_in_names
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def test_spaces_in_names():
"""Test that spaces in filenames are errors."""
package = MockXPI({
"foo/bar/foo.bar ": None,
"foo/bar/ foo.bar": None,
})
err = ErrorBundle()
packagelayout.test_blacklisted_files(err, package)
assert err.failed()
assert len(err.errors) == 2
示例10: test_prepare_package
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def test_prepare_package():
"Tests that the prepare_package function passes for valid data"
err = ErrorBundle()
eq_(submain.prepare_package(err, "tests/resources/main/foo.xpi"), err)
assert not err.failed()
示例11: TestCase
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
class TestCase(object):
def setUp(self):
self.err = None
self.is_bootstrapped = False
self.detected_type = None
self.listed = True
def reset(self):
"""
Reset the test case so that it can be run a second time (ideally with
different parameters).
"""
self.err = None
def setup_err(self):
"""
Instantiate the error bundle object. Use the `instant` parameter to
have it output errors as they're generated. `for_appversions` may be set
to target the test cases at a specific Gecko version range.
An existing error bundle will be overwritten with a fresh one that has
the state that the test case was setup with.
"""
self.err = ErrorBundle(instant=True,
listed=getattr(self, "listed", True))
self.err.handler = OutputHandler(sys.stdout, True)
def assert_failed(self, with_errors=False, with_warnings=None):
"""
First, asserts that the error bundle registers a failure (recognizing
whether warnings are acknowledged). Second, if with_errors is True,
the presence of errors is asserted. If it is not true (default), it
is tested that errors are not present. If with_warnings is not None,
the presence of warnings is tested just like with_errors)
"""
assert self.err.failed(fail_on_warnings=with_warnings or
with_warnings is None), \
"Test did not fail; failure was expected."
if with_errors:
assert self.err.errors, "Errors were expected."
elif self.err.errors:
raise AssertionError("Tests found unexpected errors: %s" %
self.err.print_summary(verbose=True))
if with_warnings is not None:
if with_warnings:
assert self.err.warnings, "Warnings were expected."
elif self.err.warnings:
raise ("Tests found unexpected warnings: %s" %
self.err.print_summary())
def assert_notices(self):
"""
Assert that notices have been generated during the validation process.
"""
assert self.err.notices, "Notices were expected."
def assert_passes(self, warnings_pass=False):
"""
Assert that no errors have been raised. If warnings_pass is True, also
assert that there are no warnings.
"""
assert not self.failed(fail_on_warnings=not warnings_pass), \
("Test was intended to pass%s, but it did not." %
(" with warnings" if warnings_pass else ""))
def assert_silent(self):
"""
Assert that no messages (errors, warnings, or notices) have been
raised.
"""
assert not self.err.errors, 'Got these: %s' % self.err.errors
assert not self.err.warnings, 'Got these: %s' % self.err.warnings
assert not self.err.notices, 'Got these: %s' % self.err.notices
def assert_got_errid(self, errid):
"""
Assert that a message with the given errid has been generated during
the validation process.
"""
assert any(msg["id"] == errid for msg in
(self.err.errors + self.err.warnings + self.err.notices)), \
"%s was expected, but it was not found." % repr(errid)
示例12: test_prepare_package_webapp
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def test_prepare_package_webapp(fake_webapp_validator):
fake_webapp_validator.expects_call().with_arg_count(2)
err = ErrorBundle()
submain.prepare_package(err, "tests/resources/main/mozball.webapp")
assert not err.failed()
示例13: test_crazy_unicode
# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import failed [as 别名]
def test_crazy_unicode():
err = ErrorBundle()
with open('tests/resources/spidermonkey_unicode.js', 'r') as f:
scripting.test_js_file(err, "foo.js", f.read())
assert not err.failed(), err.errors + err.warnings