def main(): arguments = __get_arguments() path = arguments.path pattern = arguments.pattern if path and isfile(path): path, pattern = split(path) if not path: path = os.curdir if arguments.no_color: for color_name, value in inspect.getmembers(Fore): if not color_name.startswith('_'): setattr(Fore, color_name, '') if arguments.cover and COVERAGE_AVAILABLE: cov = coverage(source=arguments.cover_package, omit=arguments.cover_omit) cov.erase() cov.start() verbosity = len(arguments.verbosity) if arguments.verbosity else 2 result, reporter = run(path, pattern, verbosity, arguments.progress) if result.successful and arguments.cover: if COVERAGE_AVAILABLE: cov.stop() print print xml = '' with tempfile.NamedTemporaryFile() as tmp: cov.xml_report(outfile=tmp.name) tmp.seek(0) xml = tmp.read() if arguments.cover_report: with open(arguments.cover_report, 'w') as report: report.write(xml) reporter.print_coverage(xml, arguments.cover_threshold) else: print print Fore.YELLOW + "WARNING: Cover disabled because coverage could not be found." print Fore.YELLOW + "Make sure it is installed and accessible" print reporter.pretty_print() if arguments.xunit_output: xunit = XUnitReporter(result) xunit.write_report(arguments.xunit_file) if arguments.profile: reporter.print_profile(arguments.profile_threshold) sys.exit(result.errored_tests)
def main(): arguments = __get_arguments() path = arguments.path pattern = arguments.pattern if path and isfile(path): path, pattern = split(path) if not path: path = os.curdir if arguments.cover and COVERAGE_AVAILABLE: cov = coverage(source=arguments.cover_package, omit=arguments.cover_omit) cov.erase() cov.start() result, reporter = run(path, pattern) if arguments.cover and COVERAGE_AVAILABLE: cov.stop() if arguments.cover and COVERAGE_AVAILABLE: print print xml = '' with tempfile.NamedTemporaryFile() as tmp: cov.xml_report(outfile=tmp.name) tmp.seek(0) xml = tmp.read() if arguments.cover_report: with open(arguments.cover_report, 'w') as report: report.write(xml) reporter.print_coverage(xml, arguments.cover_threshold) if arguments.cover and not COVERAGE_AVAILABLE: init(autoreset=True) print print Fore.YELLOW + "WARNING: Cover disabled because coverage or lxml could not be found." print Fore.YELLOW + "Make sure both are installed and accessible" print if arguments.xunit_output: xunit = XUnitReporter(result, arguments.xunit_file) xunit.write_report() if result.successful: sys.exit(0) else: sys.exit(1)
def topic(self): result = ResultMock() result.successful_tests = 0 result.errored_tests = 0 result.ellapsed_time = 0 result.contexts = [] reporter = XUnitReporter(result) return reporter
def topic(self): result = ResultMock() result.successful_tests = 1 result.errored_tests = 0 result.ellapsed_time = 0 result.contexts = [ { 'name': 'Context1', 'tests': [ { 'name': 'Test1', 'succeeded': True } ], 'contexts': [] } ] reporter = XUnitReporter(result) return reporter.create_report_document().firstChild.firstChild