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


Python errorbundle.ErrorBundle类代码示例

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


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

示例1: 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:JaredKerim-Mozilla,项目名称:app-validator,代码行数:7,代码来源:test_submain.py

示例2: 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:JaredKerim-Mozilla,项目名称:app-validator,代码行数:7,代码来源:test_submain.py

示例3: _test_xul_raw

def _test_xul_raw(data, path, should_fail=False, should_fail_csp=None,
                  type_=None):
    filename = path.split("/")[-1]
    extension = filename.split(".")[-1]

    err = ErrorBundle()
    if type_:
        err.set_type(type_)

    parser = markuptester.MarkupParser(err, debug=True)
    parser.process(filename, data, extension)

    print err.print_summary(verbose=True)

    if should_fail:
        assert any(m for m in (err.errors + err.warnings) if
                   m["id"][0] != "csp")
    else:
        assert not any(m for m in (err.errors + err.warnings) if
                       m["id"][0] != "csp")

    if should_fail_csp == True:
        assert any(m for m in (err.errors + err.warnings) if
                   m["id"][0] == "csp")
    elif should_fail_csp == False:
        assert not any(m for m in (err.errors + err.warnings) if
                       m["id"][0] == "csp")

    return err
开发者ID:dimonov,项目名称:app-validator,代码行数:29,代码来源:test_markup_markuptester.py

示例4: test_prepare_package_webapp

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

示例5: test_version_control

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()
开发者ID:JaredKerim-Mozilla,项目名称:app-validator,代码行数:8,代码来源:test_packagelayout.py

示例6: test_boring

def test_boring():
    """Test that boring output strips out color sequences."""

    # Use the StringIO as an output buffer.
    bundle = ErrorBundle()
    bundle.error((), "<<BLUE>><<GREEN>><<YELLOW>>")
    bundle.print_summary(no_color=True)

    sys.stdout.seek(0)
    eq_(sys.stdout.getvalue().count("<<GREEN>>"), 0)
开发者ID:andrew361x,项目名称:perfalator,代码行数:10,代码来源:test_errorbundler.py

示例7: test_duplicate_files

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()
开发者ID:JaredKerim-Mozilla,项目名称:app-validator,代码行数:10,代码来源:test_packagelayout.py

示例8: test_spaces_in_names

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
开发者ID:JaredKerim-Mozilla,项目名称:app-validator,代码行数:12,代码来源:test_packagelayout.py

示例9: _do_test

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
开发者ID:dimonov,项目名称:app-validator,代码行数:14,代码来源:test_markup_csstester.py

示例10: test_notice_friendly

def test_notice_friendly():
    """
    Test notice-related human-friendly text output functions of the error
    bundler.
    """

    # Use the StringIO as an output buffer.
    bundle = ErrorBundle()

    bundle.notice((), "foobar")

    # Load the JSON output as an object.
    output = bundle.print_summary(verbose=True, no_color=True)
    print output

    assert output.count("foobar")
开发者ID:andrew361x,项目名称:perfalator,代码行数:16,代码来源:test_errorbundler.py

示例11: test_json

def test_json():
    """Test the JSON output capability of the error bundler."""

    # Use the StringIO as an output buffer.
    bundle = ErrorBundle() # No color since no output
    bundle.set_tier(4)
    bundle.set_tier(3)

    bundle.error((), "error", "description")
    bundle.warning((), "warning", "description")
    bundle.notice((), "notice", "description")

    results = json.loads(bundle.render_json())

    eq_(len(results["messages"]), 3)
    assert not results["success"]
    eq_(results["ending_tier"], 4)
开发者ID:andrew361x,项目名称:perfalator,代码行数:17,代码来源:test_errorbundler.py

示例12: setup_err

    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)
开发者ID:mnoorenberghe,项目名称:app-validator,代码行数:12,代码来源:helper.py

示例13: test_notice

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)
开发者ID:andrew361x,项目名称:perfalator,代码行数:27,代码来源:test_errorbundler.py

示例14: _do_test

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
开发者ID:mnoorenberghe,项目名称:app-validator,代码行数:19,代码来源:helper.py

示例15: test_message_completeness

def test_message_completeness():
    """Test we're fully expecting all of the values for a message."""

    bundle = ErrorBundle()

    bundle.error(
        ("id", ),
        "error",
        "description",
        "file",
        123,  # line
        456  # column
    )

    results = json.loads(bundle.render_json())
    eq_(len(results["messages"]), 1, "Unexpected number of messages.")

    message = results["messages"][0]
    eq_(message["id"], ["id"])
    eq_(message["message"], "error")
    eq_(message["description"], "description")
    eq_(message["file"], "file")
    eq_(message["line"], 123)
    eq_(message["column"], 456)
开发者ID:andrew361x,项目名称:perfalator,代码行数:24,代码来源:test_errorbundler.py


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