Ejemplo n.º 1
0
    def display_slowest_tests(self, stream):
        table = prettytable.PrettyTable(["Elapsed", "File", "Method"])
        table.align["Method"] = "l"
        table.align["File"] = "l"

        stream.writeln("Per test breakdown")

        slowest_tests = TestTime.get_slowest_tests(10)
        for row in slowest_tests:
            table.add_row(
                [
                    "{:.05f}s".format(row["elapsed"]),
                    row["file"],
                    "{}.{}.{}".format(row["module"], row["class"], row["func"]),
                ]
            )

        stream.writeln(table.get_string())
        stream.writeln()

        stream.writeln("Per file breakdown")
        table = prettytable.PrettyTable(["Elapsed", "File"])
        table.align["File"] = "l"
        slowest_files = TestTime.get_slowest_files(10)
        for row in slowest_files:
            table.add_row(["{:.05f}s".format(row["sum_elapsed"]), row["file"]])
        stream.writeln(table.get_string())
        stream.writeln()

        stream.writeln("*** Total test time: {:.05f}s".format(TestTime.get_total_time()))
Ejemplo n.º 2
0
    def display_slowest_tests(self, stream):
        table = prettytable.PrettyTable(['Elapsed', 'File', 'Method'])
        table.align['Method'] = 'l'
        table.align['File'] = 'l'

        stream.writeln('Per test breakdown')

        slowest_tests = TestTime.get_slowest_tests(10)
        for row in slowest_tests:
            table.add_row(['{:.05f}s'.format(row['elapsed']),
                           row['file'],
                           '{}.{}.{}'.format(
                               row['module'], row['class'], row['func'])])

        stream.writeln(table.get_string())
        stream.writeln()

        stream.writeln('Per file breakdown')
        table = prettytable.PrettyTable(['Elapsed', 'File'])
        table.align['File'] = 'l'
        slowest_files = TestTime.get_slowest_files(10)
        for row in slowest_files:
            table.add_row(['{:.05f}s'.format(row['sum_elapsed']),
                           row['file']])
        stream.writeln(table.get_string())
        stream.writeln()

        stream.writeln('*** Total test time: {:.05f}s'.format(TestTime.get_total_time()))
Ejemplo n.º 3
0
    def write(cls, html_file):
        """Writes the HTML report to the given file."""
        f = open(html_file, 'w')
        f.write('<html>')
        f.write('<head>')
        f.write('</head>')
        f.write('<body>')
        f.write('<h1>Test times</h1>')

        fmt_test = '<tr><td>{:.05f}</td><td>{}</td></tr><tr><td>&nbsp;</td><td>{}</td></tr>'

        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in TestTime.get_slowest_tests(10):
            f.write(
                fmt_test.format(
                    row['elapsed'], row['file'],
                    '{}.{}.{}'.format(row['module'], row['class'],
                                      row['func'])))
        f.write('</table>')

        fmt_file = '<tr><td>{:.05f}</td><td>{}</td></tr>'
        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in TestTime.get_slowest_files(10):
            f.write(fmt_file.format(row['sum_elapsed'], row['file']))
        f.write('</table>')

        f.write('<h1>Setup times</h1>')

        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in SetupTime.get_slowest_tests(10):
            f.write(
                fmt_test.format(
                    row['elapsed'], row['file'],
                    '{}.{}.{}'.format(row['module'], row['class'],
                                      row['func'])))
        f.write('</table>')

        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in SetupTime.get_slowest_files(10):
            f.write(fmt_file.format(row['sum_elapsed'], row['file']))
        f.write('</table>')

        f.write('</body>')
        f.write('</html>')

        f.close()
Ejemplo n.º 4
0
    def write(cls, html_file):
        """Writes the HTML report to the given file."""
        f = open(html_file, 'w')
        f.write('<html>')
        f.write('<head>')
        f.write('</head>')
        f.write('<body>')
        f.write('<h1>Test times</h1>')
        
        fmt_test = '<tr><td>{:.05f}</td><td>{}</td></tr><tr><td>&nbsp;</td><td>{}</td></tr>'

        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in TestTime.get_slowest_tests(10):
            f.write(fmt_test.format(row['elapsed'], row['file'], '{}.{}.{}'.format(row['module'], row['class'], row['func'])))
        f.write('</table>')


        fmt_file = '<tr><td>{:.05f}</td><td>{}</td></tr>'
        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in TestTime.get_slowest_files(10):
            f.write(fmt_file.format(row['sum_elapsed'], row['file']))
        f.write('</table>')

        
        f.write('<h1>Setup times</h1>')

        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in SetupTime.get_slowest_tests(10):
            f.write(fmt_test.format(row['elapsed'], row['file'], '{}.{}.{}'.format(row['module'], row['class'], row['func'])))
        f.write('</table>')


        f.write('<table>')
        f.write('<tr><th>Time</th><th>Test info</th></tr>')
        for row in SetupTime.get_slowest_files(10):
            f.write(fmt_file.format(row['sum_elapsed'], row['file']))
        f.write('</table>')

        
        f.write('</body>')
        f.write('</html>')

        f.close()