def test_package(err, file_, name, expectation=PACKAGE_ANY, for_appversions=None):
    'Begins tests for the package.'
    try:
        package = XPIManager(file_, mode='r', name=name)
        has_package_json = ('package.json' in package)
        has_manifest_json = ('manifest.json' in package)
        has_install_rdf = ('install.rdf' in package)
        if has_package_json:
            _load_package_json(err, package, expectation)
        if has_manifest_json:
            _load_manifest_json(err, package, expectation)
        if has_install_rdf:
            _load_install_rdf(err, package, expectation)
    except IOError:
        err.error(('main', 'test_package', 'unopenable'), 'The XPI could not be opened.')
        return
    except (BadZipfile, zlib_error):
        err.error(('submain', '_load_install_rdf', 'badzipfile'), error='Corrupt ZIP file', description='We were unable to decompress the zip file.')
        return
    if (package.extension in assumed_extensions):
        assumed_type = assumed_extensions[package.extension]
        if (expectation not in (PACKAGE_ANY, assumed_type)):
            err.error(('main', 'test_package', 'unexpected_type'), 'Unexpected package type (found theme)')
    test_inner_package(err, package, for_appversions)
Begins tests for the package.
def test_package(err, file_, name, expectation=PACKAGE_ANY, for_appversions=None):
    
    try:
        package = XPIManager(file_, mode='r', name=name)
        has_package_json = ('package.json' in package)
        has_manifest_json = ('manifest.json' in package)
        has_install_rdf = ('install.rdf' in package)
        if has_package_json:
            _load_package_json(err, package, expectation)
        if has_manifest_json:
            _load_manifest_json(err, package, expectation)
        if has_install_rdf:
            _load_install_rdf(err, package, expectation)
    except IOError:
        err.error(('main', 'test_package', 'unopenable'), 'The XPI could not be opened.')
        return
    except (BadZipfile, zlib_error):
        err.error(('submain', '_load_install_rdf', 'badzipfile'), error='Corrupt ZIP file', description='We were unable to decompress the zip file.')
        return
    if (package.extension in assumed_extensions):
        assumed_type = assumed_extensions[package.extension]
        if (expectation not in (PACKAGE_ANY, assumed_type)):
            err.error(('main', 'test_package', 'unexpected_type'), 'Unexpected package type (found theme)')
    test_inner_package(err, package, for_appversions)