本文整理汇总了Python中validator.xpi.XPIManager.test方法的典型用法代码示例。如果您正苦于以下问题:Python XPIManager.test方法的具体用法?Python XPIManager.test怎么用?Python XPIManager.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validator.xpi.XPIManager
的用法示例。
在下文中一共展示了XPIManager.test方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad_file
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_bad_file():
"Tests that the XPI manager correctly reports a bad XPI file."
x = XPIManager("tests/resources/junk.xpi")
assert not x.zf
x = XPIManager("tests/resources/corrupt.xpi")
assert x.test()
示例2: test_bad_file
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_bad_file():
"""Tests that the XPI manager correctly reports a bad XPI file."""
try:
x = XPIManager(get_path("junk.xpi"))
except BadZipfile:
pass
x = XPIManager(get_path("corrupt.xpi"))
assert x.test()
示例3: test_bad_file
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_bad_file():
"Tests that the XPI manager correctly reports a bad XPI file."
try:
x = XPIManager("tests/resources/junk.xpi")
except zipfile.BadZipfile:
pass
x = XPIManager("tests/resources/corrupt.xpi")
assert x.test()
示例4: clean_xpifile
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def clean_xpifile(self):
"Make sure that the uploaded file is a valid XPI file."
xpifile = self.cleaned_data['xpifile']
if xpifile:
try:
xpi = XPIManager(xpifile, name=xpifile.name)
if xpi.test():
raise
except:
raise forms.ValidationError(_("File doesn't seem to be valid XPI"))
return xpifile
示例5: test_package
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_package(err, file_, name, expectation=PACKAGE_ANY,
for_appversions=None):
"Begins tests for the package."
# Load up a new instance of an XPI.
try:
package = XPIManager(file_, mode="r", name=name)
except:
# Die on this one because the file won't open.
return err.error(("main",
"test_package",
"unopenable"),
"The XPI could not be opened.")
# Test the XPI file for corruption.
if package.test():
return err.error(("main",
"test_package",
"corrupt"),
"XPI package appears to be corrupt.")
if package.extension in assumed_extensions:
assumed_type = assumed_extensions[package.extension]
# Is the user expecting a different package type?
if not expectation in (PACKAGE_ANY, assumed_type):
err.error(("main",
"test_package",
"unexpected_type"),
"Unexpected package type (found theme)")
# Test the install.rdf file to see if we can get the type that way.
has_install_rdf = "install.rdf" in package
if has_install_rdf:
_load_install_rdf(err, package, expectation)
try:
output = test_inner_package(err, package, for_appversions)
except ValidationTimeout as ex:
err.error(
err_id=("main", "test_package", "timeout"),
error="Validation timed out",
description=["The validation process took too long to "
"complete. Contact an addons.mozilla.org editor "
"for more information.",
str(ex)])
output = None
return output
示例6: test_package
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_package(err, file_, name, expectation=PACKAGE_ANY):
"Begins tests for the package."
# Load up a new instance of an XPI.
package = XPIManager(file_, name)
if not package.zf:
# Die on this one because the file won't open.
return err.error(("main",
"test_package",
"unopenable"),
"The XPI could not be opened.")
# Test the XPI file for corruption.
if package.test():
err.reject = True
return err.error(("main",
"test_package",
"corrupt"),
"XPI package appears to be corrupt.")
if package.extension in assumed_extensions:
assumed_type = assumed_extensions[package.extension]
# Is the user expecting a different package type?
if not expectation in (PACKAGE_ANY, assumed_type):
err.error(("main",
"test_package",
"unexpected_type"),
"Unexpected package type (found theme)")
# Cache a copy of the package contents.
package_contents = package.get_file_data()
# Test the install.rdf file to see if we can get the type that way.
has_install_rdf = "install.rdf" in package_contents
if has_install_rdf:
_load_install_rdf(err, package, expectation)
return test_inner_package(err, package_contents, package)
示例7: test_package
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_package(err, file_, name, expectation=PACKAGE_ANY,
for_appversions=None):
"Begins tests for the package."
# Load up a new instance of an XPI.
try:
package = XPIManager(file_, mode="r", name=name)
except:
# Die on this one because the file won't open.
return err.error(("main",
"test_package",
"unopenable"),
"The XPI could not be opened.")
# Test the XPI file for corruption.
if package.test():
return err.error(("main",
"test_package",
"corrupt"),
"XPI package appears to be corrupt.")
if package.extension in assumed_extensions:
assumed_type = assumed_extensions[package.extension]
# Is the user expecting a different package type?
if not expectation in (PACKAGE_ANY, assumed_type):
err.error(("main",
"test_package",
"unexpected_type"),
"Unexpected package type (found theme)")
# Test the install.rdf file to see if we can get the type that way.
has_install_rdf = "install.rdf" in package
if has_install_rdf:
_load_install_rdf(err, package, expectation)
return test_inner_package(err, package, for_appversions)
示例8: test_valid_name
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_valid_name():
"Test that the manager can retrieve the correct file name"
z = XPIManager("tests/resources/xpi/install_rdf_only.xpi")
contents = z.get_file_data()
assert "install.rdf" in contents
assert z.test() == False
示例9: test_valid_name
# 需要导入模块: from validator.xpi import XPIManager [as 别名]
# 或者: from validator.xpi.XPIManager import test [as 别名]
def test_valid_name():
"Test that the manager can retrieve the correct file name."
z = XPIManager(get_path("xpi/install_rdf_only.xpi"))
contents = z.package_contents()
assert "install.rdf" in contents
assert z.test() == False