Beispiel #1
0
 def addAssert(self, test_info, assertName, varList, exception):
     BaseReporter.addAssert(self, test_info, assertName, varList, exception)
     if self.immediate and self.vassert:
         self._write(
             "\n  " +
             self._vassertMessage(assertName, varList, exception is None))
         self.multiLineOutput = True
Beispiel #2
0
    def done(self):
        BaseReporter.done(self)
        # create result table
        from reportlab.lib import colors
        from reportlab.platypus import SimpleDocTemplate, Table, TableStyle

        table = Table(self.test_data)
        table.setStyle(
            TableStyle(
                [
                    ("INNERGRID", (0, 0), (-1, -1), 0.25, colors.black),
                    ("BOX", (0, 0), (-1, -1), 0.25, colors.black),
                    ("VALIGN", (0, 0), (-1, -1), "TOP"),
                    ("BACKGROUND", (0, 0), (-1, 0), colors.grey),
                ]
            )
        )

        for i in xrange(1, len(self.test_data)):
            if self.test_data[i][1] == "Success":
                color = colors.green
            else:
                color = colors.red
            table.setStyle(TableStyle([("TEXTCOLOR", (1, i), (1, i), color)]))
        self.lst.append(table)
        if self.cover_amount != None:
            self._print_coverage(self.cover_amount, self.coverage)
        SimpleDocTemplate(self.filename).build(self.lst)
Beispiel #3
0
    def addSkip(self, test_info, err_info, isRegistered=True):
        BaseReporter.addSkip(self, test_info, err_info, isRegistered)

        def add_elements():
            self.writer.element("reason", err_info.exception_value())

        self._add_testcase_element(test_info, "skip")
Beispiel #4
0
 def start(self):
     BaseReporter.start(self)
     self._pbg = ProgressBarGuiThread(
         num_tests=self.parameters["num_tests"],
     )
     self._pbg.start()
     self._pbg.wait_until_ready()
     if self._pbg.error:
         raise self._pbg.error[1]
Beispiel #5
0
    def done(self):
        BaseReporter.done(self)

        # TODO: deal with runner.startTime and runner.stopTime
        runner = get_runner()
        import datetime
        runner.stopTime = datetime.datetime.now()

        self.stream.write(runner.generateReportString(self))
Beispiel #6
0
    def done(self):
        BaseReporter.done(self)

        # TODO: deal with runner.startTime and runner.stopTime
        runner = get_runner()
        import datetime
        runner.stopTime = datetime.datetime.now()

        self.stream.write( runner.generateReportString(self) )
Beispiel #7
0
    def __init__(self, filename):
        BaseReporter.__init__(self)

        from cStringIO import StringIO
        self._sio = StringIO()
        from elementtree.SimpleXMLWriter import XMLWriter
        self.writer = XMLWriter(self._sio, "utf-8")
        self.filename = filename

        self.test_starts = {}
Beispiel #8
0
    def __init__(self, filename):
        BaseReporter.__init__(self)

        from cStringIO import StringIO
        self._sio = StringIO()
        from elementtree.SimpleXMLWriter import XMLWriter
        self.writer = XMLWriter(self._sio, "utf-8")
        self.filename = filename

        self.test_starts = {}
Beispiel #9
0
    def stopTest(self, test_info):
        BaseReporter.stopTest(self, test_info)
        if self.vassert and not self.immediate:
            self._printVasserts(test_info)
        if self.time_each_test:
            self.writers.normal.write(" [%.2f seconds]" %
                                      self.current_test_total_time)

        if self.showAll:
            self._writeln("")
Beispiel #10
0
    def done(self):
        BaseReporter.done(self)

        self.writer.element("total_time", value="%.4f" % self.total_time)
        self.writer.end("testsuites")

        if self.cover_amount is not None and self.cover_amount == "xml":
            self._write_coverage(self.coverage)

        self.writer.end("results")
Beispiel #11
0
    def done(self):
        BaseReporter.done(self)

        self.writer.element("total_time", value="%.4f"%self.total_time)
        self.writer.end("testsuites")

        if self.cover_amount is not None and self.cover_amount == "xml":
            self._write_coverage(self.coverage)

        self.writer.end("results")
Beispiel #12
0
    def done(self):
        BaseReporter.done(self)
        self.writer.end("table")
        self.writer.element("p", "Total time: %.4f"%self.total_time)
        self.writer.end("body")
        self.writer.end("html")

        #assert len(self.test_starts) == 0
        f = file(self.filename, "w")
        try: f.write(self._getHtml())
        finally: f.close()
Beispiel #13
0
    def stopTest(self, test_info):
        BaseReporter.stopTest(self, test_info)
        if self.vassert and not self.immediate:
            self._printVasserts(test_info)
        if self.time_each_test:
            self.writers.normal.write(
                " [%.2f seconds]" % self.current_test_total_time
            )

        if self.showAll:
            self._writeln("")
Beispiel #14
0
    def __init__(self, filename):
        BaseReporter.__init__(self)
        from reportlab.platypus import XPreformatted, Spacer
        self.filename = filename
        self.lst = []
        self.lst.append(
            XPreformatted(
                "<b><i><font size=20>Summary of test results</font></i></b>",
                self._normal_style()))
        self.lst.append(Spacer(0, 20))

        self.test_data = [("Name", "Result", "Info")]
Beispiel #15
0
    def __init__(self):
        BaseReporter.__init__(self)

        from cStringIO import StringIO
        self._sio = StringIO()
        try:
            from elementtree.SimpleXMLWriter import XMLWriter
        except ImportError:
            from testoob.compatibility.SimpleXMLWriter import XMLWriter
        self.writer = XMLWriter(self._sio, "utf-8")

        self.test_starts = {}
Beispiel #16
0
    def __init__(self):
        BaseReporter.__init__(self)

        from cStringIO import StringIO
        self._sio = StringIO()
        try:
            from elementtree.SimpleXMLWriter import XMLWriter
        except ImportError:
            from testoob.compatibility.SimpleXMLWriter import XMLWriter
        self.writer = XMLWriter(self._sio, "utf-8")

        self.test_starts = {}
Beispiel #17
0
    def __init__(self, filename):
        BaseReporter.__init__(self)
        from reportlab.platypus import XPreformatted, Spacer

        self.filename = filename
        self.lst = []
        self.lst.append(
            XPreformatted("<b><i><font size=20>Summary of test results</font></i></b>", self._normal_style())
        )
        self.lst.append(Spacer(0, 20))

        self.test_data = [("Name", "Result", "Info")]
Beispiel #18
0
    def done(self):
        BaseReporter.done(self)
        self.writer.end("table")
        self.writer.element("p", "Total time: %.4f" % self.total_time)
        self.writer.end("body")
        self.writer.end("html")

        #assert len(self.test_starts) == 0
        f = file(self.filename, "w")
        try:
            f.write(self._getHtml())
        finally:
            f.close()
Beispiel #19
0
    def stopTest(self, test_info):
        BaseReporter.stopTest(self, test_info)
        if self.vassert and not self.immediate:
            self._printVasserts(test_info)
        if self.time_each_test:
            self.writers.normal.write(
                " [%.2f seconds]" % self.current_test_total_time
            )

        # If a test is skipped because of a KeyboardInterrupt, it will be re-run
        # to make it explicitely skipped. In those cases, you don't want a newline
        # yet. In all other cases, you'd like to have a newline in verbose mode
        # to close off the "OK", "SKIPPED", "FAIL", or "ERROR" strings
        self._write_newline_after_result_if_necessary()
Beispiel #20
0
    def __init__(self, stream, create_writers = StreamWriters):
        # TODO - why the hell do we save re?
        import re
        self.re = re
        BaseReporter.__init__(self)
        self.writers = create_writers(stream)

        from testoob.reporting import options
        self.showAll = options.verbosity > 1
        self.dots = options.verbosity == 1
        self.vassert = options.verbosity == 3
        self.immediate = options.immediate
        self.descriptions = options.descriptions
        self.time_each_test = options.time_each_test
Beispiel #21
0
    def __init__(self, stream, create_writers=StreamWriters):
        # TODO - why the hell do we save re?
        import re
        self.re = re
        BaseReporter.__init__(self)
        self.writers = create_writers(stream)

        from testoob.reporting import options
        self.showAll = options.verbosity > 1
        self.dots = options.verbosity == 1
        self.vassert = options.verbosity == 3
        self.immediate = options.immediate
        self.descriptions = options.descriptions
        self.time_each_test = options.time_each_test
Beispiel #22
0
    def __init__(self, stream):
        BaseReporter.__init__(self)

        self.stream = stream

        self.success_count = 0
        self.failure_count = 0
        self.error_count = 0

        # result is a list of result in 4 tuple
        # (
        #   result code (0: success; 1: fail; 2: error),
        #   TestCase object,
        #   Test output (byte string),
        #   stack trace,
        # )
        self.result = []
Beispiel #23
0
 def addSkip(self, test_info, err_info, isRegistered=True):
     # addSkip can be called after or before stopTest:
     # 1) If a testcase is skipped programmatically, addSkip
     #    is called before stopTest, as expected
     # 2) If a testcase is skipped using keyboard interrupt,
     #    the testcase is rerun with a new decorator that
     #    calls addSkip, causing it to be run after stopTest.
     # When adding the newline after SKIPPED, this has to be
     # taken into account.
     BaseReporter.addSkip(self, test_info, err_info, isRegistered)
     self._report_result("SKIPPED", "S", self.writers.warning)
     # newline needed here because newline added in stopTest gets
     # printed before SKIPPED does, if the root-cause was a 
     # keyboardInterrupt, which can be recognized by an empty
     # exception value.
     if err_info.exc_info[2] is None:
         self._write_newline_after_result_if_necessary()
Beispiel #24
0
    def __init__(self, stream):
        BaseReporter.__init__(self)

        self.stream = stream

        self.success_count = 0
        self.failure_count = 0
        self.error_count = 0

        # result is a list of result in 4 tuple
        # (
        #   result code (0: success; 1: fail; 2: error),
        #   TestCase object,
        #   Test output (byte string),
        #   stack trace,
        # )
        self.result = []
Beispiel #25
0
    def done(self):
        BaseReporter.done(self)

        if self.dots or self.showAll:
            self._write("\n")

        if not self.immediate:
            self._printErrors()

        if len(self.skips) > 0:
            self._printSkipped()

        if len(self.errors) > 0:
            self._printShortErrors("Erred", self.errors)

        if len(self.failures) > 0:
            self._printShortErrors("Failed", self.failures)

        self._writeln(self.separator2)
        self._printResults()
Beispiel #26
0
    def done(self):
        BaseReporter.done(self)

        if self.dots or self.showAll:
            self._write("\n")

        if not self.immediate:
            self._printErrors()

        if len(self.skips) > 0:
            self._printSkipped()

        if len(self.errors) > 0:
            self._printShortErrors("Erred", self.errors)

        if len(self.failures) > 0:
            self._printShortErrors("Failed", self.failures)

        self._writeln(self.separator2)
        self._printResults()
Beispiel #27
0
    def done(self):
        BaseReporter.done(self)
        #create result table
        from reportlab.lib import colors
        from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
        table = Table(self.test_data)
        table.setStyle(
            TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                        ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
                        ('VALIGN', (0, 0), (-1, -1), "TOP"),
                        ('BACKGROUND', (0, 0), (-1, 0), colors.grey)]))

        for i in xrange(1, len(self.test_data)):
            if (self.test_data[i][1] == "Success"):
                color = colors.green
            else:
                color = colors.red
            table.setStyle(TableStyle([('TEXTCOLOR', (1, i), (1, i), color)]))
        self.lst.append(table)
        if (self.cover_amount != None):
            self._print_coverage(self.cover_amount, self.coverage)
        SimpleDocTemplate(self.filename).build(self.lst)
Beispiel #28
0
 def addAssert(self, test_info, assertName, varList, exception):
     BaseReporter.addAssert(self, test_info, assertName, varList, exception)
     if self.immediate and self.vassert:
         self._write("\n  " + self._vassertMessage(assertName, varList, exception is None))
         self.multiLineOutput = True
Beispiel #29
0
 def start(self):
     BaseReporter.start(self)
     self._writeHeader()
Beispiel #30
0
 def startTest(self, test_info):
     BaseReporter.startTest(self, test_info)
     self.test_starts[test_info] = time.time()
Beispiel #31
0
 def addFailure(self, test_info, err_info):
     BaseReporter.addFailure(self, test_info, err_info)
     self._add_unsuccessful_testcase("failure", test_info, err_info)
Beispiel #32
0
 def startTest(self, test_info):
     BaseReporter.startTest(self, test_info)
     self.test_starts[test_info] = time.time()
Beispiel #33
0
 def start(self):
     BaseReporter.start(self)
     self.writer.start("results")
     self.writer.start("testsuites")
Beispiel #34
0
 def addSkip(self, test_info, err_info, isRegistered=True):
     # TODO: why does addSkip get called _after_ stopTest?
     BaseReporter.addSkip(self, test_info, err_info, isRegistered)
     # newline needed because newline added in stopTest gets printed before
     # SKIPPED does
     self._report_result("SKIPPED\n", "S", self.writers.warning)
Beispiel #35
0
 def startTest(self, test_info):
     BaseReporter.startTest(self, test_info)
     self.multiLineOutput = False
     if self.showAll:
         self._write(self.getDescription(test_info))
         self._write(" ... ")
Beispiel #36
0
 def addError(self, test_info, err_info):
     BaseReporter.addError(self, test_info, err_info)
     self.error_count += 1
     self.result.append((2, test_info.classname(), '', str(err_info)))
Beispiel #37
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self.test_data.append((str(test_info), "Success", ""))
Beispiel #38
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._sio.write(HTMLReporter._SuccessTemplate%(str(test_info), self._test_time(test_info)))
Beispiel #39
0
 def addError(self, test_info, err_info):
     BaseReporter.addError(self, test_info, err_info)
     self._report_failure(
         "ERROR", "E", self.writers.failure, test_info, err_info)
Beispiel #40
0
 def addSkip(self, test_info, err_info, isRegistered=True):
     BaseReporter.addSkip(self, test_info, err_info, isRegistered)
     self._sio.write(HTMLReporter._SkipTemplate %
                     (str(test_info), self._test_time(test_info),
                      str(err_info.exception_value())))
Beispiel #41
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._sio.write(HTMLReporter._SuccessTemplate %
                     (str(test_info), self._test_time(test_info)))
Beispiel #42
0
 def addFailure(self, test_info, err_info):
     BaseReporter.addFailure(self, test_info, err_info)
     self._add_unsuccessful_testcase("failure", test_info, err_info)
Beispiel #43
0
 def addSkip(self, test_info, err_info, isRegistered=True):
     BaseReporter.addSkip(self, test_info, err_info, isRegistered)
     def add_elements():
         self.writer.element( "reason", err_info.exception_value() )
     self._add_testcase_element(test_info, "skip")
Beispiel #44
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._report_result("OK", ".", self.writers.success)
Beispiel #45
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self.success_count += 1
     self.result.append((0, test_info.classname(), '', ''))
Beispiel #46
0
 def addError(self, test_info, err_info):
     BaseReporter.addError(self, test_info, err_info)
     self._add_unsuccessful_testcase("error", test_info, err_info)
Beispiel #47
0
 def addFailure(self, test_info, err_info):
     BaseReporter.addFailure(self, test_info.classname(), err_info)
     self.failure_count += 1
     self.result.append((1, test_info.classname(), '', str(err_info)))
Beispiel #48
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._add_testcase_element(test_info, "success")
Beispiel #49
0
 def addError(self, test_info, err_info):
     BaseReporter.addError(self, test_info, err_info)
     self._report_failure("ERROR", "E", self.writers.failure, test_info,
                          err_info)
Beispiel #50
0
 def addError(self, test_info, err_info):
     BaseReporter.addError(self, test_info, err_info)
     self._add_unsuccessful_testcase("error", test_info, err_info)
Beispiel #51
0
 def addFailure(self, test_info, err_info):
     BaseReporter.addFailure(self, test_info, err_info)
     self._report_failure("FAIL", "F", self.writers.failure, test_info,
                          err_info)
Beispiel #52
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._add_testcase_element(test_info, "success")
Beispiel #53
0
 def addFailure(self, test_info, err_info):
     BaseReporter.addFailure(self, test_info.classname(), err_info)
     self.failure_count += 1
     self.result.append((1, test_info.classname(), '', str(err_info)))
Beispiel #54
0
 def startTest(self, test_info):
     BaseReporter.startTest(self, test_info)
     self.multiLineOutput = False
     if self.showAll:
         self._write(self.getDescription(test_info))
         self._write(" ... ")
Beispiel #55
0
 def addSkip(self, test_info, err_info, isRegistered=True):
     BaseReporter.addSkip(self, test_info, err_info, isRegistered)
     self._sio.write(HTMLReporter._SkipTemplate%(str(test_info), self._test_time(test_info), str(err_info.exception_value())))
Beispiel #56
0
 def addError(self, test_info, err_info):
     BaseReporter.addError(self, test_info, err_info)
     self.error_count += 1
     self.result.append((2, test_info.classname(), '', str(err_info)))
Beispiel #57
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._report_result("OK", ".", self.writers.success)
Beispiel #58
0
 def addFailure(self, test_info, err_info):
     BaseReporter.addFailure(self, test_info, err_info)
     self._report_failure(
         "FAIL", "F", self.writers.failure, test_info, err_info)
Beispiel #59
0
 def start(self):
     BaseReporter.start(self)
     self.writer.start("results")
     self.writer.start("testsuites")