Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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]
Ejemplo n.º 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))
Ejemplo n.º 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) )
Ejemplo n.º 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 = {}
Ejemplo n.º 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 = {}
Ejemplo n.º 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("")
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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()
Ejemplo n.º 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("")
Ejemplo n.º 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")]
Ejemplo n.º 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 = {}
Ejemplo n.º 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 = {}
Ejemplo n.º 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")]
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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 = []
Ejemplo n.º 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()
Ejemplo n.º 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 = []
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 29
0
 def start(self):
     BaseReporter.start(self)
     self._writeHeader()
Ejemplo n.º 30
0
 def startTest(self, test_info):
     BaseReporter.startTest(self, test_info)
     self.test_starts[test_info] = time.time()
Ejemplo n.º 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)
Ejemplo n.º 32
0
 def startTest(self, test_info):
     BaseReporter.startTest(self, test_info)
     self.test_starts[test_info] = time.time()
Ejemplo n.º 33
0
 def start(self):
     BaseReporter.start(self)
     self.writer.start("results")
     self.writer.start("testsuites")
Ejemplo n.º 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)
Ejemplo n.º 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(" ... ")
Ejemplo n.º 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)))
Ejemplo n.º 37
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self.test_data.append((str(test_info), "Success", ""))
Ejemplo n.º 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)))
Ejemplo n.º 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)
Ejemplo n.º 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())))
Ejemplo n.º 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)))
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 44
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._report_result("OK", ".", self.writers.success)
Ejemplo n.º 45
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self.success_count += 1
     self.result.append((0, test_info.classname(), '', ''))
Ejemplo n.º 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)
Ejemplo n.º 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)))
Ejemplo n.º 48
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._add_testcase_element(test_info, "success")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 52
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._add_testcase_element(test_info, "success")
Ejemplo n.º 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)))
Ejemplo n.º 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(" ... ")
Ejemplo n.º 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())))
Ejemplo n.º 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)))
Ejemplo n.º 57
0
 def addSuccess(self, test_info):
     BaseReporter.addSuccess(self, test_info)
     self._report_result("OK", ".", self.writers.success)
Ejemplo n.º 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)
Ejemplo n.º 59
0
 def start(self):
     BaseReporter.start(self)
     self.writer.start("results")
     self.writer.start("testsuites")