当前位置: 首页>>代码示例>>Python>>正文


Python XPIManager.test方法代码示例

本文整理汇总了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()
开发者ID:nmaier,项目名称:amo-validator,代码行数:10,代码来源:test_xpimanager.py

示例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()
开发者ID:robhudson,项目名称:amo-validator,代码行数:10,代码来源:test_xpimanager.py

示例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()
开发者ID:krupa,项目名称:amo-validator,代码行数:12,代码来源:test_xpimanager.py

示例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
开发者ID:rmoorman,项目名称:transifex-adofex,代码行数:13,代码来源:forms.py

示例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
开发者ID:andymckay,项目名称:amo-validator,代码行数:50,代码来源:submain.py

示例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)
开发者ID:nmaier,项目名称:amo-validator,代码行数:40,代码来源:submain.py

示例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)
开发者ID:clouserw,项目名称:amo-validator,代码行数:38,代码来源:submain.py

示例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
开发者ID:nmaier,项目名称:amo-validator,代码行数:8,代码来源:test_xpimanager.py

示例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
开发者ID:robhudson,项目名称:amo-validator,代码行数:8,代码来源:test_xpimanager.py


注:本文中的validator.xpi.XPIManager.test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。