Skip to content

Commit

Permalink
Merge pull request #563 from reubenmiller/skip-deprecated-options-bas…
Browse files Browse the repository at this point in the history
…ed-on-version

fix: exclude deprecated options based on RF version
  • Loading branch information
mkorpela committed Jan 20, 2024
2 parents 7101fc8 + 77ce241 commit a7fd543
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
24 changes: 18 additions & 6 deletions src/pabot/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,33 @@ def _processes_count(): # type: () -> int
return 2


def _filter_argument_parser_options(**options):
# Note: auto_pythonpath is deprecated since RobotFramework 5.0, but only
# communicated to users from 6.1
if ROBOT_VERSION >= "5.0" and "auto_pythonpath" in options:
del options["auto_pythonpath"]
return options


def parse_args(
args,
): # type: (List[str]) -> Tuple[Dict[str, object], List[str], Dict[str, object], Dict[str, object]]
args, pabot_args = _parse_pabot_args(args)
options, datasources = ArgumentParser(
USAGE,
auto_pythonpath=False,
auto_argumentfile=True,
env_options="ROBOT_OPTIONS",
**_filter_argument_parser_options(
auto_pythonpath=False,
auto_argumentfile=True,
env_options="ROBOT_OPTIONS",
),
).parse_args(args)
options_for_subprocesses, sources_without_argfile = ArgumentParser(
USAGE,
auto_pythonpath=False,
auto_argumentfile=False,
env_options="ROBOT_OPTIONS",
**_filter_argument_parser_options(
auto_pythonpath=False,
auto_argumentfile=False,
env_options="ROBOT_OPTIONS",
),
).parse_args(args)
if len(datasources) != len(sources_without_argfile):
raise DataError(
Expand Down
27 changes: 20 additions & 7 deletions src/pabot/pabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@
from robot.utils import PY2, SYSTEM_ENCODING, ArgumentParser, is_unicode

from . import pabotlib, __version__ as PABOT_VERSION
from .arguments import parse_args, parse_execution_item_line
from .arguments import (
parse_args,
parse_execution_item_line,
_filter_argument_parser_options,
)
from .clientwrapper import make_order
from .execution_items import (
DynamicSuiteItem,
Expand Down Expand Up @@ -638,9 +642,11 @@ def _options_for_executor(
def _modify_options_for_argfile_use(argfile, options, root_name):
argfile_opts, _ = ArgumentParser(
USAGE,
auto_pythonpath=False,
auto_argumentfile=True,
env_options="ROBOT_OPTIONS",
**_filter_argument_parser_options(
auto_pythonpath=False,
auto_argumentfile=True,
env_options="ROBOT_OPTIONS",
),
).parse_args(["--argumentfile", argfile])
old_name = options.get("name", root_name)
if argfile_opts["name"]:
Expand Down Expand Up @@ -1142,9 +1148,16 @@ def generate_suite_names_with_builder(outs_dir, datasources, options):
if "pythonpath" in opts:
del opts["pythonpath"]
settings = RobotSettings(opts)
builder = TestSuiteBuilder(
settings["SuiteNames"], settings.extension, rpa=settings.rpa
)

# Note: first argument (included_suites) is deprecated from RobotFramework 6.1
if ROBOT_VERSION < "6.1":
builder = TestSuiteBuilder(
settings["SuiteNames"], settings.extension, rpa=settings.rpa
)
else:
builder = TestSuiteBuilder(
included_extensions=settings.extension, rpa=settings.rpa
)
suite = builder.build(*datasources)
settings.rpa = builder.rpa
suite.configure(**settings.suite_config)
Expand Down

0 comments on commit a7fd543

Please sign in to comment.