def test_shuffle(self): arr = [1, 2, 3, 4, 5, 6, 7, 8] shuffled = list(arr) sorter = ordering.ShuffleSorter(seed=5) sorter.randomizer.shuffle(shuffled) assert shuffled != arr assert sorter.sorted_instances(arr) == shuffled assert sorter.sorted_testsuites(arr) == shuffled assert sorter.sorted_testcases(arr) == shuffled
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
def test_sorted_testsuites(self, shuffle_types, expected): sorter = ordering.ShuffleSorter(seed=5, shuffle_type=shuffle_types) arr = [1, 2, 3, 4, 5] assert expected == sorter.sorted_testsuites(arr)
# Case 1, noop, original declaration & insertion order (ordering.NoopSorter(), [ ('Multitest', [ ('Beta', ['test_ccc', 'test_xxx', 'test_aaa']), ('Alpha', ['test_ccc', 'test_bbb', 'test_aaa']), ]), ]), # Case 2, alphanumerical (ordering.AlphanumericSorter(), [ ('Multitest', [ ('Alpha', ['test_aaa', 'test_bbb', 'test_ccc']), ('Beta', ['test_aaa', 'test_ccc', 'test_xxx']), ]), ]), # Case 3, shuffle all (ordering.ShuffleSorter(seed=7), [ ('Multitest', py_version_data( py2=[ ('Alpha', ['test_bbb', 'test_aaa', 'test_ccc']), ('Beta', ['test_xxx', 'test_aaa', 'test_ccc']), ], py3=[ ('Beta', ['test_aaa', 'test_ccc', 'test_xxx']), ('Alpha', ['test_aaa', 'test_ccc', 'test_bbb']), ], )) ]), # # Case 4, shuffle suites (ordering.ShuffleSorter(seed=7, shuffle_type='suites'), [ ('Multitest',
"test_yyy", [ "test_yyy <val=1>", "test_yyy <val=2>", "test_yyy <val=3>", ], ), ], ), ], ) ], ), # Case 3, shuffle all ( ordering.ShuffleSorter(seed=7), [ ( "Multitest", [ ( "Beta", [ ( "test_yyy", [ "test_yyy <val=1>", "test_yyy <val=3>", "test_yyy <val=2>", ], ),