• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python errorbundler.ErrorBundle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中validator.errorbundler.ErrorBundle的典型用法代码示例。如果您正苦于以下问题:Python ErrorBundle类的具体用法?Python ErrorBundle怎么用?Python ErrorBundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ErrorBundle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_jar_nonsubpackage

def test_jar_nonsubpackage():
    "Tests XPI files that are not subpackages."

    err = ErrorBundle()
    err.set_type(PACKAGE_MULTI)
    err.save_resource("is_multipackage", True)
    mock_package = MockXPI(
        {"foo.jar":
             "tests/resources/content/subpackage.jar",
         "chrome/bar.jar":
             "tests/resources/content/subpackage.jar"})

    content.testendpoint_validator = MockTestEndpoint(("test_inner_package",
                                                       "test_package"))

    result = content.test_packed_packages(
                                    err,
                                    mock_package)
    print result
    assert result == 2
    content.testendpoint_validator.assert_expectation(
                                    "test_package",
                                    2)
    content.testendpoint_validator.assert_expectation(
                                    "test_package",
                                    0,
                                    "subpackage")
开发者ID:malyshkosergey,项目名称:amo-validator,代码行数:27,代码来源:test_content.py


示例2: test_jar_subpackage

def test_jar_subpackage():
    "Tests JAR files that are subpackages."

    err = ErrorBundle()
    err.set_type(PACKAGE_EXTENSION)
    err.supported_versions = {"foo": ["1.2.3"]}
    mock_package = MockXPI(
        {"chrome/subpackage.jar":
             "tests/resources/content/subpackage.jar",
         "subpackage.jar":
             "tests/resources/content/subpackage.jar"})

    content.testendpoint_validator = \
        MockTestEndpoint(("test_inner_package", ))

    result = content.test_packed_packages(
                                    err,
                                    mock_package)
    print result
    assert result == 2
    content.testendpoint_validator.assert_expectation(
                                    "test_inner_package",
                                    2)
    content.testendpoint_validator.assert_expectation(
                                    "test_inner_package",
                                    2,
                                    "subpackage")
    assert err.supported_versions == {"foo": ["1.2.3"]}
开发者ID:malyshkosergey,项目名称:amo-validator,代码行数:28,代码来源:test_content.py


示例3: test_prepare_package_missing

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


示例4: test_prepare_package_bad_file

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


示例5: _test

def _test(script):
    err = ErrorBundle()
    err.supported_versions = {}
    err.save_resource("em:bootstrap", "true")
    scripting.test_js_file(err, "foo", script)

    return err
开发者ID:almet,项目名称:amo-validator,代码行数:7,代码来源:test_js_bootstrapped.py


示例6: test_prepare_package

def test_prepare_package(test_package):
    """Tests that the prepare_package does not raise any errors when given
    a valid add-on."""

    err = ErrorBundle()
    submain.prepare_package(err, 'tests/resources/main/foo.xpi')
    assert not err.failed()
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:7,代码来源:test_submain.py


示例7: test_structure

 def test_structure(structure):
     err = ErrorBundle()
     err.supported_versions = {}
     mock_package = MockXPI(structure)
     content.test_packed_packages(err, mock_package)
     print err.print_summary(verbose=True)
     assert err.failed()
开发者ID:l-hedgehog,项目名称:amo-validator,代码行数:7,代码来源:test_content.py


示例8: test_version_forappversions_accepted

def test_version_forappversions_accepted():
    """
    Test that for_appversions targets application versions properly.
    """

    err = ErrorBundle()
    err.supported_versions = {'firefox': ['1.2.3']}

    tests = decorator.TEST_TIERS
    decorator.TEST_TIERS = {}

    @decorator.register_test(tier=5, versions={'firefox': ['1.0.0',
                                                           '1.2.3']})
    def version_test(err, xpi):
        print 'Ran test'
        err.save_resource('executed', True)

    print decorator.TEST_TIERS

    validator.submain.test_inner_package(err, MockXPI(),
                                         for_appversions={'firefox':
                                                              ['1.2.3']})

    assert err.get_resource('executed')
    decorator.TEST_TIERS = tests
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:25,代码来源:test_submain_versions.py


示例9: _do_test

def _do_test(xpi_package, allow_old_sdk=True, compat=False):

    err = ErrorBundle()
    if compat:
        err.save_resource('is_compat_test', True)
    jetpack.inspect_jetpack(err, xpi_package, allow_old_sdk=allow_old_sdk)
    return err
开发者ID:AutomatedTester,项目名称:amo-validator,代码行数:7,代码来源:test_jetpack.py


示例10: test_notice

def test_notice():
    """Tests 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()
开发者ID:nmaier,项目名称:amo-validator,代码行数:26,代码来源:test_errorbundler.py


示例11: setup_err

def setup_err(package_json=None, err=None):
    if err is None:
        err = ErrorBundle()
    if package_json is not None:
        err.save_resource("has_package_json", True)
        err.save_resource("package_json", package_json)
    return err
开发者ID:myrdd,项目名称:amo-validator,代码行数:7,代码来源:test_packagejson.py


示例12: setup_err

def setup_err(manifest_json=None, err=None):
    if err is None:
        err = ErrorBundle()
    if manifest_json is not None:
        err.save_resource('has_manifest_json', True)
        err.save_resource('manifest_json', manifest_json)
    return err
开发者ID:kumar303,项目名称:amo-validator,代码行数:7,代码来源:test_manifestjson.py


示例13: test_langpack

def test_langpack():
    "Tests a language pack in the content validator."
    
    err = ErrorBundle(None, True)
    err.set_type(PACKAGE_LANGPACK)
    mock_package = MockXPIManager(
        {"foo.dtd":
             "tests/resources/content/junk.xpi"})
                        
    content.testendpoint_langpack = \
        MockTestEndpoint(("test_unsafe_html", ))
    
    result = content.test_packed_packages(
                                    err,
                                    {"foo.dtd":
                                      {"extension": "dtd",
                                       "name_lower": "foo.dtd"}},
                                    mock_package)
    print result
    assert result == 1
    content.testendpoint_langpack.assert_expectation(
                                    "test_unsafe_html",
                                    1)
    content.testendpoint_langpack.assert_expectation(
                                    "test_unsafe_html",
                                    0,
                                    "subpackage")
开发者ID:nmaier,项目名称:amo-validator,代码行数:27,代码来源:test_content.py


示例14: test_proper_linked_manifest_relative

def test_proper_linked_manifest_relative():
    """
    Test that linked manifests are imported relatively when using relative
    paths.
    """

    err = ErrorBundle()
    package = MockXPI(
        {
            "chrome.manifest": "tests/resources/submain/linkman/subdir.manifest",
            "dir/level2.manifest": "tests/resources/submain/linkman/foosub.manifest",
            "dir/foo.manifest": "tests/resources/submain/linkman/base2.manifest",
        }
    )

    submain.populate_chrome_manifest(err, package)
    chrome = err.get_resource("chrome.manifest")
    assert chrome

    assert not err.failed() or err.notices

    # From the linked manifest:
    zaps = list(chrome.get_entries("zap"))
    assert zaps
    eq_(zaps[0]["filename"], "dir/foo.manifest")
    eq_(zaps[0]["context"].data, ["zap baz", ""])
开发者ID:kmaglione,项目名称:amo-validator,代码行数:26,代码来源:test_submain.py


示例15: test_xpi_subpackage

def test_xpi_subpackage():
    "XPIs should never be subpackages; only nested extensions"

    err = ErrorBundle()
    err.set_type(PACKAGE_EXTENSION)
    mock_package = MockXPI(
        {"chrome/package.xpi":
             "tests/resources/content/subpackage.jar"})

    content.testendpoint_validator = \
        MockTestEndpoint(("test_package", ))

    result = content.test_packed_packages(
        err,
        mock_package)

    print result
    assert result == 1
    content.testendpoint_validator.assert_expectation(
        "test_package",
        1)
    content.testendpoint_validator.assert_expectation(
        "test_package",
        0,
        "subpackage")
开发者ID:malyshkosergey,项目名称:amo-validator,代码行数:25,代码来源:test_content.py


示例16: test_webapp_pass

def test_webapp_pass():
    """Test that a bland webapp file throws no errors."""

    err = ErrorBundle()
    validator.webapp.detect_webapp(err, json.dumps(_get_json()))
    print err.print_summary(verbose=True)
    assert not err.failed()
开发者ID:malyshkosergey,项目名称:amo-validator,代码行数:7,代码来源:test_webapp.py


示例17: test_duplicate_files

def test_duplicate_files():
    """Test that duplicate files in a package are caught."""

    err = ErrorBundle()
    err.save_resource("has_install_rdf", True)
    packagelayout.test_layout_all(err, MockDupeXPI())
    assert err.failed()
开发者ID:wagnerand,项目名称:amo-validator,代码行数:7,代码来源:test_packagelayout.py


示例18: validate

def validate(
    path,
    format="json",
    approved_applications=os.path.join(os.path.dirname(__file__), "app_versions.json"),
    determined=True,
    spidermonkey=False,
    listed=True,
    expectation=PACKAGE_ANY,
):
    """Perform validation in one easy step!
    
    format : The format to output the results in
    approved_applications : Path to the list of approved application versions
    determined : Whether the validator should continue after a tier fails
    spidermonkey : Path to the local spidermonkey installation (Default: False)
    listed : True if the add-on is destined for AMO, false if not
    expectation : The type of package that should be expected
    """

    # Load up the target applications
    apps = json.load(open(approved_applications))
    validator.testcases.targetapplication.APPROVED_APPLICATIONS = apps

    bundle = ErrorBundle(listed=listed, determined=determined)
    if spidermonkey != False:
        bundle.save_resource("SPIDERMONKEY", spidermonkey)

    validator.submain.prepare_package(bundle, path, expectation)

    # Write the results to the pipe
    formats = {"json": lambda b: b.render_json()}
    if format is not None:
        return formats[format](bundle)
    else:
        return bundle
开发者ID:nmaier,项目名称:amo-validator,代码行数:35,代码来源:validate.py


示例19: test_webapp_pass

def test_webapp_pass():
    """Test that a bland webapp file throws no errors."""

    err = ErrorBundle()
    _detect(err, _get_json())
    print err.print_summary(verbose=True)
    assert not err.failed()
开发者ID:krupa,项目名称:amo-validator,代码行数:7,代码来源:test_webapp.py


示例20: test_content_missing_information

def test_content_missing_information():
    """Test that incomplete information in a content instruction fails."""

    err = ErrorBundle()
    c = ChromeManifest("content foo", "chrome.manifest")
    err.save_resource("chrome.manifest", c)
    tc_chromemanifest.test_content_instructions(err)
    assert err.failed()
开发者ID:myrdd,项目名称:amo-validator,代码行数:8,代码来源:test_chromemanifest_testcases.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python content.test_packed_packages函数代码示例发布时间:2022-05-26
下一篇:
Python decorator.version_range函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap