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


Python ErrorBundle.print_summary方法代码示例

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


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

示例1: _test_xul_raw

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
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()
    err.save_resource("app_type", "certified")
    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:fritexvz,项目名称:app-validator,代码行数:27,代码来源:test_markup_markuptester.py

示例2: test_boring

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
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,代码行数:12,代码来源:test_errorbundler.py

示例3: _do_test

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
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,代码行数:16,代码来源:test_markup_csstester.py

示例4: test_file_structure

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
def test_file_structure():
    """
    Test the means by which file names and line numbers are stored in errors,
    warnings, and messages.
    """

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

    # Populate the bundle with some test data.
    bundle.error((), "error", "", "file1", 123)
    bundle.error((), "error", "", "file2")

    bundle.warning((), "warning", "", "file4", 123)
    bundle.warning((), "warning", "", "file5")
    bundle.warning((), "warning")

    # Load the JSON output as an object.
    output = json.loads(bundle.render_json())

    # Do the same for friendly output
    output2 = bundle.print_summary(verbose=False)

    # Do the same for verbose friendly output
    output3 = bundle.print_summary(verbose=True)

    # Run some basic tests
    eq_(len(output["messages"]), 5)
    assert len(output2) < len(output3)

    messages = ["file1", "file2", "", "file4", "file5"]

    for message in output["messages"]:
        print message

        assert message["file"] in messages
        messages.remove(message["file"])

        if isinstance(message["file"], list):
            pattern = message["file"][:]
            pattern.pop()
            pattern.append("")
            file_merge = " > ".join(pattern)
            print file_merge
            assert output3.count(file_merge)
        else:
            assert output3.count(message["file"])

    assert not messages
开发者ID:andrew361x,项目名称:perfalator,代码行数:51,代码来源:test_errorbundler.py

示例5: _do_test

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
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,代码行数:21,代码来源:helper.py

示例6: test_notice_friendly

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
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,代码行数:18,代码来源:test_errorbundler.py

示例7: TestCase

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
class TestCase(object):
    def setUp(self):
        self.err = None
        self.is_bootstrapped = False
        self.detected_type = None
        self.listed = True

    def reset(self):
        """
        Reset the test case so that it can be run a second time (ideally with
        different parameters).
        """
        self.err = None

    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)

    def assert_failed(self, with_errors=False, with_warnings=None):
        """
        First, asserts that the error bundle registers a failure (recognizing
        whether warnings are acknowledged). Second, if with_errors is True,
        the presence of errors is asserted. If it is not true (default), it
        is tested that errors are not present. If with_warnings is not None,
        the presence of warnings is tested just like with_errors)
        """
        assert self.err.failed(fail_on_warnings=with_warnings or
                                                with_warnings is None), \
                "Test did not fail; failure was expected."

        if with_errors:
            assert self.err.errors, "Errors were expected."
        elif self.err.errors:
            raise AssertionError("Tests found unexpected errors: %s" %
                                self.err.print_summary(verbose=True))

        if with_warnings is not None:
            if with_warnings:
                assert self.err.warnings, "Warnings were expected."
            elif self.err.warnings:
                raise ("Tests found unexpected warnings: %s" %
                           self.err.print_summary())

    def assert_notices(self):
        """
        Assert that notices have been generated during the validation process.
        """
        assert self.err.notices, "Notices were expected."

    def assert_passes(self, warnings_pass=False):
        """
        Assert that no errors have been raised. If warnings_pass is True, also
        assert that there are no warnings.
        """
        assert not self.failed(fail_on_warnings=not warnings_pass), \
                ("Test was intended to pass%s, but it did not." %
                     (" with warnings" if warnings_pass else ""))

    def assert_silent(self):
        """
        Assert that no messages (errors, warnings, or notices) have been
        raised.
        """
        assert not self.err.errors, 'Got these: %s' % self.err.errors
        assert not self.err.warnings, 'Got these: %s' % self.err.warnings
        assert not self.err.notices, 'Got these: %s' % self.err.notices

    def assert_got_errid(self, errid):
        """
        Assert that a message with the given errid has been generated during
        the validation process.
        """
        assert any(msg["id"] == errid for msg in
                   (self.err.errors + self.err.warnings + self.err.notices)), \
                "%s was expected, but it was not found." % repr(errid)
开发者ID:mnoorenberghe,项目名称:app-validator,代码行数:86,代码来源:helper.py

示例8: ErrorBundle

# 需要导入模块: from appvalidator.errorbundle import ErrorBundle [as 别名]
# 或者: from appvalidator.errorbundle.ErrorBundle import print_summary [as 别名]
                  help="Path to test, or directory containing tests. "
                       "Directories will be recursively searched."
parser.add_option("-v", "--verbose", dest="verbose",
                  default=False,
                  action="store_true",
                  help="Use verbose mode for output.")

opt, args = parser.parse_args()

if os.path.isfile(opt.test):
    files = [opt.test]
else:
    files = []
    for root, folders, fileList in os.walk(opt.test):
        for f in fileList:
            files.append(os.path.join(root,f))

bundle = ErrorBundle()
for name in files:
    print name
    f = open(name, 'r')
    if name.endswith('.js'):
        test_js_file(bundle, name, f.read())
    else:
        soup = BeautifulSoup(f.read())
        for script in soup.find_all('script'):
            test_js_snippet(bundle, script.renderContents(), name)
    f.close()

print bundle.print_summary(verbose=opt.verbose)
开发者ID:chmanchester,项目名称:test-validator,代码行数:32,代码来源:validator.py


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