Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/testing/mozbase/mozlog/mozlog/formatters/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  unittest.py   Sprache: Python

 
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


from . import base


class UnittestFormatter(base.BaseFormatter):
    """Formatter designed to produce output in a format like that used by
    the ``unittest`` module in the standard library."""

    def __init__(self):
        self.fails = []
        self.errors = []
        self.tests_run = 0
        self.start_time = None
        self.end_time = None

    def suite_start(self, data):
        self.start_time = data["time"]

    def test_start(self, data):
        self.tests_run += 1

    def test_end(self, data):
        char = "."
        if "expected" in data:
            status = data["status"]
            char = {"FAIL""F""PRECONDITION_FAILED""F""ERROR""E""PASS""X"}[
                status
            ]

            if status == "FAIL" or status == "PRECONDITION_FAILED":
                self.fails.append(data)
            elif status == "ERROR":
                self.errors.append(data)

        elif data["status"] == "SKIP":
            char = "S"
        return char

    def assertion_count(self, data):
        if data["count"] < data["min_expected"]:
            char = "X"
        elif data["count"] > data["max_expected"]:
            char = "F"
            self.fails.append(
                {
                    "test": data["test"],
                    "message": (
                        "assertion count %i is greated than %i"
                        % (data["count"], data["max_expected"])
                    ),
                }
            )
        elif data["count"] > 0:
            char = "."
        else:
            char = "."

        return char

    def suite_end(self, data):
        self.end_time = data["time"]
        summary = "\n".join(
            [self.output_fails(), self.output_errors(), self.output_summary()]
        )
        return "\n%s\n" % summary

    def output_fails(self):
        return "\n".join("FAIL %(test)s\n%(message)s\n" % data for data in self.fails)

    def output_errors(self):
        return "\n".join("ERROR %(test)s\n%(message)s" % data for data in self.errors)

    def output_summary(self):
        # pylint --py3k W1619
        return "Ran %i tests in %.1fs" % (
            self.tests_run,
            (self.end_time - self.start_time) / 1000,
        )

Messung V0.5
C=92 H=91 G=91

¤ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.