Skip to content

Commit

Permalink
running black
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorpela committed Dec 4, 2024
1 parent 0a7d994 commit 64521a0
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 116 deletions.
11 changes: 7 additions & 4 deletions src/pabot/SharedLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class SharedLibrary(object):

ROBOT_LIBRARY_SCOPE = "GLOBAL"

def __init__(self, name, args=None):
Expand All @@ -26,8 +25,10 @@ def __init__(self, name, args=None):
"Not currently running pabot. Importing library for this process."
)
self._lib = RemoteLibraryFactory(
TestLibrary.from_name(name, args=args, variables=None, create_keywords=True).instance
if ROBOT_VERSION >= "7.0"
TestLibrary.from_name(
name, args=args, variables=None, create_keywords=True
).instance
if ROBOT_VERSION >= "7.0"
else TestLibrary(name, args=args).get_instance()
)
return
Expand All @@ -36,7 +37,9 @@ def __init__(self, name, args=None):
remotelib = Remote(uri) if uri else None
if remotelib:
try:
port = remotelib.run_keyword("import_shared_library", [name], {"args": args})
port = remotelib.run_keyword(
"import_shared_library", [name], {"args": args}
)
except RuntimeError:
logger.error("No connection - is pabot called with --pabotlib option?")
raise
Expand Down
1 change: 1 addition & 0 deletions src/pabot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import

from .pabotlib import PabotLib

__version__ = "4.0.0"
32 changes: 18 additions & 14 deletions src/pabot/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,24 @@ def _parse_pabot_args(args): # type: (List[str]) -> Tuple[List[str], Dict[str,
}
# Explicitly define argument types for validation
flag_args = {
"verbose", "help", "testlevelsplit", "pabotlib",
"artifactsinsubfolders", "chunk"
"verbose",
"help",
"testlevelsplit",
"pabotlib",
"artifactsinsubfolders",
"chunk",
}
value_args = {
"hive": str,
"processes": lambda x: int(x) if x != 'all' else None,
"processes": lambda x: int(x) if x != "all" else None,
"resourcefile": str,
"pabotlibhost": str,
"pabotlibport": int,
"processtimeout": int,
"ordering": _parse_ordering,
"suitesfrom": str,
"artifacts": lambda x: x.split(","),
"shard": _parse_shard
"shard": _parse_shard,
}

argumentfiles = []
Expand All @@ -119,11 +123,11 @@ def _parse_pabot_args(args): # type: (List[str]) -> Tuple[List[str], Dict[str,

while i < len(args):
arg = args[i]
if not arg.startswith('--'):
if not arg.startswith("--"):
remaining_args.append(arg)
i += 1
continue

arg_name = arg[2:] # Strip '--'

if arg_name == "no-pabotlib":
Expand All @@ -135,23 +139,23 @@ def _parse_pabot_args(args): # type: (List[str]) -> Tuple[List[str], Dict[str,
saw_pabotlib_flag = True
args = args[1:]
continue

# Special case for command
if arg_name == "command":
try:
end_index = args.index("--end-command", i)
pabot_args["command"] = args[i+1:end_index]
pabot_args["command"] = args[i + 1 : end_index]
i = end_index + 1
continue
except ValueError:
raise DataError("--command requires matching --end-command")

# Handle flag arguments
if arg_name in flag_args:
pabot_args[arg_name] = True
i += 1
continue

# Handle value arguments
if arg_name in value_args:
if i + 1 >= len(args):
Expand All @@ -166,7 +170,7 @@ def _parse_pabot_args(args): # type: (List[str]) -> Tuple[List[str], Dict[str,
continue
except (ValueError, TypeError) as e:
raise DataError(f"Invalid value for --{arg_name}: {args[i + 1]}")

# Handle argument files
match = ARGSMATCHER.match(arg)
if match:
Expand All @@ -175,14 +179,14 @@ def _parse_pabot_args(args): # type: (List[str]) -> Tuple[List[str], Dict[str,
argumentfiles.append((match.group(1), args[i + 1]))
i += 2
continue

# If we get here, it's a non-pabot argument
remaining_args.append(arg)
i += 1

if saw_pabotlib_flag and saw_no_pabotlib:
raise DataError("Cannot use both --pabotlib and --no-pabotlib options together")

pabot_args["argumentfiles"] = argumentfiles
return remaining_args, pabot_args

Expand Down
15 changes: 2 additions & 13 deletions src/pabot/execution_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

@total_ordering
class ExecutionItem(object):

isWait = False
type = None # type: str
name = None # type: str
Expand Down Expand Up @@ -51,7 +50,6 @@ def __repr__(self):


class HivedItem(ExecutionItem):

type = "hived"

def __init__(self, item, hive):
Expand All @@ -67,7 +65,6 @@ def name(self):


class GroupItem(ExecutionItem):

type = "group"

def __init__(self):
Expand Down Expand Up @@ -128,7 +125,6 @@ def line(self):


class SuiteItem(RunnableItem):

type = "suite"

def __init__(self, name, tests=None, suites=None, dynamictests=None):
Expand Down Expand Up @@ -163,9 +159,9 @@ def __eq__(self, other):
return False
if self.name == other.name:
return True
if other.name.endswith('.'+self.name):
if other.name.endswith("." + self.name):
return True
if self.name.endswith('.'+other.name):
if self.name.endswith("." + other.name):
return True
return False

Expand All @@ -178,7 +174,6 @@ def tags(self):


class TestItem(RunnableItem):

type = "test"

def __init__(self, name):
Expand Down Expand Up @@ -229,7 +224,6 @@ def modify_options_for_executor(self, options):


class DynamicTestItem(ExecutionItem):

type = "dynamictest"

def __init__(self, name, suite):
Expand Down Expand Up @@ -258,7 +252,6 @@ def tags(self):


class WaitItem(ExecutionItem):

type = "wait"
isWait = True

Expand All @@ -270,7 +263,6 @@ def line(self):


class GroupStartItem(ExecutionItem):

type = "group"

def __init__(self):
Expand All @@ -281,7 +273,6 @@ def line(self):


class GroupEndItem(ExecutionItem):

type = "group"

def __init__(self):
Expand All @@ -292,7 +283,6 @@ def line(self):


class IncludeItem(ExecutionItem):

type = "include"

def __init__(self, tag):
Expand All @@ -309,7 +299,6 @@ def tags(self):


class SuiteItems(ExecutionItem):

type = "suite"

def __init__(self, suites):
Expand Down
Loading

0 comments on commit 64521a0

Please sign in to comment.