def test_subtest_handling(): data = copy.deepcopy(utils.JSON_DATA) data['tests']['with_subtests'] = {} data['tests']['with_subtests']['result'] = 'pass' data['tests']['with_subtests']['subtest'] = {} data['tests']['with_subtests']['subtest']['subtest1'] = 'fail' data['tests']['with_subtests']['subtest']['subtest2'] = 'warn' data['tests']['with_subtests']['subtest']['subtest3'] = 'crash' data['tests']['is_skip'] = {} data['tests']['is_skip']['result'] = 'skip' with utils.with_tempfile(json.dumps(data)) as sumfile: summ = summary.Summary([sumfile]) check_subtests_are_tests.description = \ "Subtests should be treated as full tests " yield check_subtests_are_tests, summ check_tests_w_subtests_are_groups.description = \ "Tests with subtests should be a group" yield check_tests_w_subtests_are_groups, summ test_removed_from_all.description = \ "Tests with subtests should not be in the tests['all'] name" yield test_removed_from_all, summ subtest_not_skip_notrun.description = \ "Skip's should not become NotRun" yield subtest_not_skip_notrun, summ
def main(): parser = argparse.ArgumentParser() parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite existing directories") parser.add_argument("-l", "--list", action="store", help="Load a newline seperated list of results. These " "results will be prepended to any Results " "specified on the command line") parser.add_argument( "-e", "--exclude-details", default=[], action="append", choices=['skip', 'pass', 'warn', 'crash' 'fail', 'all'], help="Optionally exclude the generation of HTML pages " "for individual test pages with the status(es) " "given as arguments. This speeds up HTML " "generation, but reduces the info in the HTML " "pages. May be used multiple times") parser.add_argument("summaryDir", metavar="<Summary Directory>", help="Directory to put HTML files in") parser.add_argument("resultsFiles", metavar="<Results Files>", nargs="*", help="Results files to include in HTML") args = parser.parse_args() # If args.list and args.resultsFiles are empty, then raise an error if not args.list and not args.resultsFiles: raise parser.error("Missing required option -l or <resultsFiles>") # If exclude-results has all, then change it to be all if 'all' in args.exclude_details: args.exclude_details = ['skip', 'pass', 'warn', 'crash', 'fail'] # if overwrite is requested delete the output directory if path.exists(args.summaryDir) and args.overwrite: shutil.rmtree(args.summaryDir) # If the requested directory doesn't exist, create it or throw an error checkDir(args.summaryDir, not args.overwrite) # Merge args.list and args.resultsFiles if args.list: args.resultsFiles.extend(parse_listfile(args.list)) # Create the HTML output output = summary.Summary(args.resultsFiles) output.generateHTML(args.summaryDir, args.exclude_details)
def check_sets(old, ostat, new, nstat, set_): """ Check that the statuses are added to the correct set """ old['tests']['sometest']['result'] = ostat new['tests']['sometest']['result'] = nstat with utils.with_tempfile(json.dumps(old)) as ofile: with utils.with_tempfile(json.dumps(new)) as nfile: summ = summary.Summary([ofile, nfile]) print(summ.tests) nt.assert_equal(1, len(summ.tests[set_]), msg="{0} was not appended".format(set_))
def console(input_): parser = argparse.ArgumentParser() # Set the -d and -s options as exclusive, since it's silly to call for diff # and then call for only summary excGroup1 = parser.add_mutually_exclusive_group() excGroup1.add_argument( "-d", "--diff", action="store_true", help="Only display the differences between multiple " "result files") excGroup1.add_argument("-s", "--summary", action="store_true", help="Only display the summary, not the individual " "test results") parser.add_argument("-l", "--list", action="store", help="Use test results from a list file") parser.add_argument("results", metavar="<Results Path(s)>", nargs="+", help="Space seperated paths to at least one results " "file") args = parser.parse_args(input_) # Throw an error if -d/--diff is called, but only one results file is # provided if args.diff and len(args.results) < 2: parser.error('-d/--diff cannot be specified unless two or more ' 'results files are specified') # make list of results if args.list: args.results.extend(core.parse_listfile(args.list)) # Generate the output output = summary.Summary(args.results) output.generate_text(args.diff, args.summary)
def html(input_): # Make a copy of the status text list and add all. This is used as the # argument list for -e/--exclude statuses = set(str(s) for s in status.ALL) statuses.add('all') parser = argparse.ArgumentParser() parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite existing directories") parser.add_argument("-l", "--list", action="store", help="Load a newline seperated list of results. These " "results will be prepended to any Results " "specified on the command line") parser.add_argument("-e", "--exclude-details", default=[], action="append", choices=statuses, help="Optionally exclude the generation of HTML pages " "for individual test pages with the status(es) " "given as arguments. This speeds up HTML " "generation, but reduces the info in the HTML " "pages. May be used multiple times") parser.add_argument("summaryDir", metavar="<Summary Directory>", help="Directory to put HTML files in") parser.add_argument("resultsFiles", metavar="<Results Files>", nargs="*", help="Results files to include in HTML") args = parser.parse_args(input_) # If args.list and args.resultsFiles are empty, then raise an error if not args.list and not args.resultsFiles: raise parser.error("Missing required option -l or <resultsFiles>") # Convert the exclude_details list to status objects, without this using # the -e option will except if args.exclude_details: # If exclude-results has all, then change it to be all if 'all' in args.exclude_details: args.exclude_details = status.ALL else: args.exclude_details = frozenset( status.status_lookup(i) for i in args.exclude_details) # if overwrite is requested delete the output directory if path.exists(args.summaryDir) and args.overwrite: shutil.rmtree(args.summaryDir) # If the requested directory doesn't exist, create it or throw an error core.checkDir(args.summaryDir, not args.overwrite) # Merge args.list and args.resultsFiles if args.list: args.resultsFiles.extend(core.parse_listfile(args.list)) # Create the HTML output output = summary.Summary(args.resultsFiles) output.generate_html(args.summaryDir, args.exclude_details)
def test_initialize_summary(): """ Test that Summary initializes """ with utils.resultfile() as tfile: test = summary.Summary([tfile.name]) assert test
def _generate_summary(self, files): return summary.Summary([path.join(self.tmpdir, i) for i in files])