def METHOD_NAME(opts, parser, extra_arg_groups=None):
    os.environ["__REZ_SELFTEST_RUNNING"] = "1"
    if opts.only_shell:
        os.environ["__REZ_SELFTEST_SHELL"] = opts.only_shell
    if not opts.module_tests and not opts.tests:
        module_tests = all_module_tests
    else:
        module_tests = opts.module_tests
    if use_pytest:
        cwd = os.getcwd()
        os.chdir(tests_dir)
        try:
            run_pytest(module_tests, opts.tests, opts.verbose,
                       extra_arg_groups)
        finally:
            os.chdir(cwd)
    else:
        run_unittest(module_tests, opts.tests, opts.verbose)