Best Python code snippet using lemoncheesecake
filter.py
Source:filter.py  
...197    def __bool__(self):198        return True199    def __call__(self, test):200        return test.path in self._tests201def _add_filter_cli_args(cli_parser, no_positional_argument=False, only_executed_tests=False):202    def property_value(value):203        splitted = value.split(":")204        if len(splitted) != 2:205            raise ValueError()206        return splitted207    group = cli_parser.add_argument_group("Filtering")208    if no_positional_argument:209        group.add_argument(210            "--path", "-p", nargs="+", help="Filter on test/suite path (wildcard character '*' can be used)"211        )212    else:213        group.add_argument(214            "path", nargs="*", default=[], help="Filter on test/suite path (wildcard character '*' can be used)"215        )216    group.add_argument(217        "--desc", nargs="+", action="append", default=[], help="Filter on descriptions"218    )219    group.add_argument(220        "--tag", "-a", nargs="+", action="append", default=[], help="Filter on tags"221    )222    group.add_argument(223        "--property", "-m", nargs="+", type=property_value, action="append", default=[], help="Filter on properties"224    )225    group.add_argument(226        "--link", "-l", nargs="+", action="append", default=[], help="Filter on links (names and URLs)"227    )228    group.add_argument(229        "--passed", action="store_true", help="Filter on passed tests"230    )231    group.add_argument(232        "--failed", action="store_true", help="Filter on failed tests"233    )234    group.add_argument(235        "--grep", "-g", help="Filter result content using pattern"236    )237    if not only_executed_tests:238        group.add_argument(239            "--skipped", action="store_true", help="Filter on skipped tests"240        )241        group.add_argument(242            "--non-passed", action="store_true", help="Alias for --failed --skipped"243        )244        group.add_argument(245            "--disabled", action="store_true", help="Filter on disabled tests"246        )247        group.add_argument(248            "--enabled", action="store_true", help="Filter on enabled (non-disabled) tests"249        )250    return group251def add_test_filter_cli_args(cli_parser):252    group = _add_filter_cli_args(cli_parser)253    group.add_argument(254        "--from-report", required=False, help="When enabled, the filtering is based on the given report"255    )256    return group257def add_result_filter_cli_args(cli_parser, only_executed_tests=False):258    return _add_filter_cli_args(cli_parser, no_positional_argument=True, only_executed_tests=only_executed_tests)259def add_step_filter_cli_args(cli_parser):260    return _add_filter_cli_args(cli_parser, no_positional_argument=True, only_executed_tests=True)261def _set_common_filter_criteria(fltr, cli_args, only_executed_tests=False):262    if not only_executed_tests and (cli_args.disabled and cli_args.enabled):263        raise UserError("--disabled and --enabled arguments are mutually exclusive")264    fltr.paths = cli_args.path265    fltr.descriptions = cli_args.desc266    fltr.tags = cli_args.tag267    fltr.properties = cli_args.property268    fltr.links = cli_args.link269    if not only_executed_tests:270        fltr.disabled = cli_args.disabled271        fltr.enabled = cli_args.enabled272def _make_test_filter(cli_args):273    if cli_args.passed or cli_args.failed or cli_args.skipped:274        raise UserError("--passed, --failed and --skipped arguments can only be used on the report-based filter")...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
