def test_create_pdf(tmpdir): """PDF exporter should generate a PDF file using the report data.""" pdf_path = tmpdir.mkdir("reports").join("dummy_report.pdf").strpath assertion_entries = [ assertions.Equal(1, 2), assertions.Greater(2, 1), assertions.IsFalse(True, "this should fail"), assertions.IsTrue(True, "this should pass"), assertions.Fail("Explicit failure"), base.Group( description="group description", entries=[ assertions.NotEqual(2, 1), assertions.Contain(1, [1, 2, 3]), ], ), ] # Test large assertion for _ in range(10): assertion_entries.append( assertions.RegexMatch("Test.*", "Testplan\n" * 500)) report = TestReport( name="my testplan", entries=[ TestGroupReport( name="My Multitest", category=ReportCategories.MULTITEST, entries=[ TestGroupReport( name="MySuite", category=ReportCategories.TESTSUITE, entries=[ TestCaseReport( name="my_test_method", entries=[ registry.serialize(obj) for obj in assertion_entries ], ) ], ) ], ) ], ) exporter = PDFExporter( pdf_path=pdf_path, pdf_style=styles.Style(passing="assertion-detail", failing="assertion-detail"), ) with log_propagation_disabled(TESTPLAN_LOGGER): exporter.export(report) assert os.path.exists(pdf_path) assert os.stat(pdf_path).st_size > 0
def test_create_pdf(tmpdir): """PDF exporter should generate a PDF file using the report data.""" pdf_path = tmpdir.mkdir('reports').join('dummy_report.pdf').strpath assertion_entries = [ assertions.Equal(1, 2), assertions.Greater(2, 1), assertions.IsFalse(True, 'this should fail'), assertions.IsTrue(True, 'this should pass'), assertions.Fail('Explicit failure'), base.Group( description='group description', entries=[ assertions.NotEqual(2, 1), assertions.Contain(1, [1, 2, 3]), ] ) ] report = TestReport( name='my testplan', entries=[ TestGroupReport( name='My Multitest', category='multitest', entries=[ TestGroupReport( name='MySuite', entries=[ TestCaseReport( name='my_test_method', entries=[ registry.serialize(obj) for obj in assertion_entries ] ) ] ) ] ) ] ) exporter = PDFExporter( pdf_path=pdf_path, pdf_style=styles.Style( passing='assertion-detail', failing='assertion-detail' ) ) with log_propagation_disabled(TESTPLAN_LOGGER): exporter.export(report) assert os.path.exists(pdf_path) assert os.stat(pdf_path).st_size > 0
def test_output_styles(): """Str label initialization should create correct StyleFlag objects.""" output_styles = styles.Style('case', 'assertion-detail') passing_style = styles.StyleFlag('case') failing_style = styles.StyleFlag('assertion-detail') assert output_styles.passing == passing_style assert output_styles.failing == failing_style assert output_styles.get_style(passing=True) == passing_style assert output_styles.get_style(passing=False) == failing_style
def process_args(self, namespace): """ Override this method to add extra argument processing logic. Can be used for interdependent argument processing. Testplan will use the result dictionary to initialize the configuration. """ args = dict(**vars(namespace)) filter_args = filtering.parse_filter_args(parsed_args=args, arg_names=("tags", "tags_all", "patterns")) if filter_args: args["test_filter"] = filter_args # Cmdline supports shuffle ordering only for now if "shuffle" in args: args["test_sorter"] = ordering.ShuffleSorter( seed=args["shuffle_seed"], shuffle_type=args["shuffle"]) # We can set arguments in @test_plan decorator or by comman line, for # arguments in boolean type if in one place it set tp True, then the # final result is True args["browse"] = args["browse"] or self._default_options["browse"] args["verbose"] = args["verbose"] or self._default_options["verbose"] args["debug"] = args["debug"] or self._default_options["debug"] # Set stdout style and logging level options according to # verbose/debug parameters. Debug output should be a superset of # verbose output, i.e. running with just "-d" should automatically # give you all "-v" output plus extra DEBUG logs. if args["verbose"] or args["debug"]: args["stdout_style"] = styles.Style( styles.StyleEnum.ASSERTION_DETAIL, styles.StyleEnum.ASSERTION_DETAIL, ) if args["debug"]: args["logger_level"] = logger.DEBUG else: args["logger_level"] = logger.INFO if args["list"] and "info" not in args: args["test_lister"] = listing.NameLister() return args
def process_args(self, namespace: argparse.Namespace) -> Dict: """ Overrides this method to add extra argument processing logic. Can be used for interdependent argument processing. Testplan uses the result dictionary to initialize the configuration. :param namespace: namespace of parsed arguments :return: initial configuration """ args = dict(**vars(namespace)) filter_args = filtering.parse_filter_args(parsed_args=args, arg_names=("tags", "tags_all", "patterns")) if filter_args: args["test_filter"] = filter_args # Cmdline supports shuffle ordering only for now if args.get("shuffle"): args["test_sorter"] = ordering.ShuffleSorter( seed=args["shuffle_seed"], shuffle_type=args["shuffle"]) # Set stdout style and logging level options according to # verbose/debug parameters. Debug output should be a superset of # verbose output, i.e. running with just "-d" should automatically # give you all "-v" output plus extra DEBUG logs. if args["verbose"] or args["debug"]: args["stdout_style"] = styles.Style( styles.StyleEnum.ASSERTION_DETAIL, styles.StyleEnum.ASSERTION_DETAIL, ) if args["debug"]: args["logger_level"] = logger.DEBUG elif args["verbose"]: args["logger_level"] = logger.INFO if args["list"] and not args["test_lister"]: args["test_lister"] = listing.NameLister() return args
def process_args(self, namespace): """ Override this method to add extra argument processing logic. Can be used for interdependent argument processing. Testplan will use the result dictionary to initialize the configuration. """ args = dict(**vars(namespace)) filter_args = filtering.parse_filter_args(parsed_args=args, arg_names=('tags', 'tags_all', 'patterns')) if filter_args: args['test_filter'] = filter_args # Cmdline supports shuffle ordering only for now if 'shuffle' in args: args['test_sorter'] = ordering.ShuffleSorter( seed=args['shuffle_seed'], shuffle_type=args['shuffle']) # Set stdout style and logging level options according to # verbose/debug parameters. Debug output should be a superset of # verbose output, i.e. running with just "-d" should automatically # give you all "-v" output plus extra DEBUG logs. if args['verbose'] or args['debug']: args['stdout_style'] = styles.Style( styles.StyleEnum.ASSERTION_DETAIL, styles.StyleEnum.ASSERTION_DETAIL) if args['debug']: args['logger_level'] = logger.DEBUG else: args['logger_level'] = logger.INFO if args['list'] and 'info' not in args: args['test_lister'] = listing.NameLister() return args
def process_args(self, namespace): """ Override this method to add extra argument processing logic. Can be used for interdependent argument processing. Testplan will use the result dictionary to initialize the configuration. """ args = dict(**vars(namespace)) filter_args = filtering.parse_filter_args(parsed_args=args, arg_names=('tags', 'tags_all', 'patterns')) if filter_args: args['test_filter'] = filter_args # Cmdline supports shuffle ordering only for now if 'shuffle' in args: args['test_sorter'] = ordering.ShuffleSorter( seed=args['shuffle_seed'], shuffle_type=args['shuffle']) if args['verbose'] is True: args['logger_level'] = testplan.logger.INFO testplan.logger.TESTPLAN_LOGGER.setLevel(testplan.logger.INFO) args['stdout_style'] = styles.Style( styles.StyleEnum.ASSERTION_DETAIL, styles.StyleEnum.ASSERTION_DETAIL) if args['debug'] is True: args['logger_level'] = testplan.logger.DEBUG testplan.logger.TESTPLAN_LOGGER.setLevel(testplan.logger.DEBUG) if args['list'] and 'info' not in args: args['test_lister'] = listing.NameLister() return args