Skip to content

Commit

Permalink
filter arg parsing options based on RF version
Browse files Browse the repository at this point in the history
New RF versions have deprecated some options which result in console warning messages being shown to users
  • Loading branch information
reubenmiller committed Jan 10, 2024
1 parent ee9a5ba commit a10d0ac
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 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
14 changes: 10 additions & 4 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

0 comments on commit a10d0ac

Please sign in to comment.