Beispiel #1
0
    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
Beispiel #2
0
    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
Beispiel #3
0
    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
Beispiel #4
0
    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
Beispiel #5
0
 "listing_obj,expected_output",
 [
     # No trim
     (
         listing.ExpandedNameLister(),
         to_stdout(
             *["Primary", "  ParametrizedSuite"]
             + [
                 "    test_method <val={}>".format(idx)
                 for idx in range(NUM_TESTS)
             ]
         ),
     ),
     # Trimmed names
     (
         listing.NameLister(),
         to_stdout(
             *["Primary", "  ParametrizedSuite"]
             + [
                 "    test_method <val={}>".format(idx)
                 for idx in range(listing.MAX_TESTCASES)
             ]
             + [
                 "    ... {} more testcases ...".format(
                     NUM_TESTS - listing.MAX_TESTCASES
                 )
             ]
         ),
     ),
     # Trimmed patterns
     (
    def test_b(self, env, result):
        pass

    @testcase(parameters=list(range(100)))
    def test_c(self, env, result, val):
        pass


# A test lister object prevents Testplan from running tests, but instead
# prints out information (list tests, counts etc) about your test setup.

# You can trigger this functionality by passing an instance of test lister
# as `test_lister` argument to `@test_plan' decorator.

# Default lister, lists by names
name_lister = listing.NameLister()

# Sample output:

# Primary
# ..Alpha
# ....test_a
# ....test_b
# ...

# Like NameLister, but does not trim testcases. May produce
# large output in case of parametrization

expanded_name_lister = listing.ExpandedNameLister()

# Pattern lister, lists tests in a format that is compatible with