Skip to content

Commit

Permalink
added RF7 support
Browse files Browse the repository at this point in the history
Signed-off-by: Rene <[email protected]>
  • Loading branch information
Snooz82 committed Dec 22, 2023
1 parent 37f58c0 commit 5913f31
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 26 deletions.
4 changes: 3 additions & 1 deletion atest/TestCases/ConfigKeyword/custom_reader.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ test default 1 2
*** Keywords ***
check vars
[Arguments] ${var_1} ${var_2}
Should Be Equal ${var_1} ${var_2}
Should Be Equal As Integers ${var_1} ${var_2}
Should Be True ${{isinstance($var1, int)}}
Should Be True ${{isinstance($var2, str)}}

Config Reader
[Arguments] ${config}
Expand Down
2 changes: 1 addition & 1 deletion atest/TestCases/Defaults/CSV/defaults.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default ${var_1} ${var_2} a a defaults This is the
*** Keywords ***
Check Variables
[Arguments] ${var_1} ${var_2} ${var_name} ${var_doc} ${var_tags}
[Arguments] ${var_1} ${var_2} ${var_name}=None ${var_doc}=None ${var_tags}=None
Verify Variable ${var_1} ${var_2} a
Verify Variable ${TEST_DOCUMENTATION} ${var_doc} This is the Default Documentation
Verify Variable ${TEST_NAME} ${var_name} defaults
Expand Down
3 changes: 1 addition & 2 deletions atest/TestCases/custom_reader/custom_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@


class custom_reader(AbstractReaderClass):

# This method will be called from DataDriver to get the TestCaseData list.
def get_data_from_source(self):
test_data = []
for i in range(int(self.min), int(self.max)): # Dummy code to just generate some data
args = {
"${var_1}": str(i),
"${var_1}": i,
"${var_2}": str(i),
} # args is a dictionary. Variable name is the key, value is value.
test_data.append(
Expand Down
4 changes: 3 additions & 1 deletion atest/TestCases/custom_reader/custom_reader.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ test default 1 2
*** Keywords ***
check vars
[Arguments] ${var_1} ${var_2}
Should Be Equal ${var_1} ${var_2}
Should Be Equal As Integers ${var_1} ${var_2}
Should Be True ${{isinstance($var1, int)}}
Should Be True ${{isinstance($var2, str)}}
4 changes: 3 additions & 1 deletion atest/TestCases/custom_reader/custom_reader_local.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ test default 1 2
*** Keywords ***
check vars
[Arguments] ${var_1} ${var_2}
Should Be Equal ${var_1} ${var_2}
Should Be Equal As Integers ${var_1} ${var_2}
Should Be True ${{isinstance($var1, int)}}
Should Be True ${{isinstance($var2, str)}}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ test default 1 2
*** Keywords ***
check vars
[Arguments] ${var_1} ${var_2}
Should Be Equal ${var_1} ${var_2}
Should Be Equal As Integers ${var_1} ${var_2}
Should Be True ${{isinstance($var1, int)}}
Should Be True ${{isinstance($var2, str)}}
4 changes: 3 additions & 1 deletion atest/TestCases/custom_reader/with_path_and_file.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ test default 1 2
*** Keywords ***
check vars
[Arguments] ${var_1} ${var_2}
Should Be Equal ${var_1} ${var_2}
Should Be Equal As Integers ${var_1} ${var_2}
Should Be True ${{isinstance($var1, int)}}
Should Be True ${{isinstance($var2, str)}}
9 changes: 8 additions & 1 deletion atest/run_atest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@

# robot -d logs --listener RobotStackTracer --exclude performanceORfailingORfiltered --loglevel TRACE:INFO --extension robot .

result = run(".", outputdir="logs", listener="RobotStackTracer", exclude="performanceORfailingORfiltered", loglevel="TRACE:INFO", extension="robot")
result = run(
".",
outputdir="logs",
listener="RobotStackTracer",
exclude="performanceORfailingORfiltered",
loglevel="TRACE:INFO",
extension="robot",
)
print(result)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ignore = [
"N801", # Class name `xxx` should use CapWords convention
"PLR0913", # Too many arguments to function call
"N999", # Invalid module name:
"PTH207", # Replace `glob` with `Path.glob` or `Path.rglob`
]
target-version = "py37"
select = [
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
with Path("Readme.rst").open(encoding="utf-8") as fh:
long_description = fh.read()

with (Path(__file__).resolve().parent / "src" / "DataDriver" / "DataDriver.py").open(encoding="utf-8") as f:
with (Path(__file__).resolve().parent / "src" / "DataDriver" / "DataDriver.py").open(
encoding="utf-8"
) as f:
VERSION = re.search('\n__version__ = "(.*)"', f.read()).group(1)

setup(
Expand All @@ -22,8 +24,6 @@
packages=find_packages("src"),
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -34,7 +34,7 @@
"Topic :: Software Development :: Testing :: Acceptance",
"Framework :: Robot Framework",
],
install_requires=["robotframework >= 4.0.2", "docutils", "Pygments"],
install_requires=["robotframework >= 4.0.2, < 8.0", "docutils", "Pygments"],
extras_require={"xls": ["pandas", "xlrd >= 1.2.0", "openpyxl"]},
python_requires=">=3.7.12",
python_requires=">=3.8.0",
)
1 change: 0 additions & 1 deletion src/DataDriver/AbstractReaderClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

class AbstractReaderClass(ABC):
def __init__(self, reader_config: ReaderConfig):

self.reader_config = reader_config
self.file = reader_config.file
self.csv_encoding = reader_config.encoding
Expand Down
20 changes: 16 additions & 4 deletions src/DataDriver/DataDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from robot.libraries.BuiltIn import BuiltIn # type: ignore
from robot.model.tags import Tags # type: ignore
from robot.model.testsuite import TestSuite # type: ignore
from robot.running import ArgInfo # type: ignore
from robot.running.model import TestCase # type: ignore
from robot.utils.dotdict import DotDict # type: ignore
from robot.utils.importer import Importer # type: ignore
Expand All @@ -34,6 +35,7 @@
ReaderConfig, # type: ignore
TestCaseData, # type: ignore
)
from .search import search_variable # type: ignore
from .utils import ( # type: ignore
Encodings,
PabotOpt,
Expand All @@ -49,7 +51,7 @@
warn,
)

__version__ = "1.9.0"
__version__ = "1.10.0"


class DataDriver:
Expand Down Expand Up @@ -1866,11 +1868,21 @@ def _replace_test_case_keywords(self):

def _get_template_arguments(self):
return_arguments = []
unassigned_arguments = []
for arg in self.template_keyword.args:
if arg in self.test_case_data.arguments:
return_arguments.append(self.test_case_data.arguments[arg])
if isinstance(arg, str):
variable_match = search_variable(arg)
arg_name = variable_match.name
elif isinstance(arg, ArgInfo):
arg_name = f"${{{arg.name}}}"
else:
return_arguments.append(arg)
raise TypeError(f"Unknown argument type: {type(arg)} (DataDriver.py: 1869)")
if arg_name in self.test_case_data.arguments:
if unassigned_arguments:
raise ValueError(f"Unassigned argument(s) detected: {unassigned_arguments}.")
return_arguments.append(self.test_case_data.arguments[arg_name])
else:
unassigned_arguments.append(arg_name)
return return_arguments

def _add_test_case_tags(self):
Expand Down
2 changes: 0 additions & 2 deletions src/DataDriver/ReaderConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class ReaderConfig:

TEST_CASE_TABLE_NAME = "*** Test Cases ***"

def __init__(
Expand All @@ -47,7 +46,6 @@ def __init__(
optimize_pabot: PabotOpt = PabotOpt.Equal,
**kwargs,
):

self.file = file
self.encoding = encoding
self.dialect = dialect
Expand Down
6 changes: 3 additions & 3 deletions src/DataDriver/argument_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def robot_options():
)
cli_args = arg_parser.parse_args(filter_args(arg_parser))[0]
try:
options = BuiltIn().get_variable_value(name='${options}')
options = BuiltIn().get_variable_value(name="${options}")
if options is not None:
cli_args['include'] = options['include']
cli_args['exclude'] = options['exclude']
cli_args["include"] = options["include"]
cli_args["exclude"] = options["exclude"]
except Exception:
pass
return cli_args
Expand Down
3 changes: 1 addition & 2 deletions src/DataDriver/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ def _validate_end_state(self, state):
items = "".join("[%s]" % i for i in self.items)
incomplete = "".join(self.item_chars)
raise VariableError(
"Variable item '{}{}[{}' was not closed "
"properly.".format(variable, items, incomplete)
f"Variable item '{variable}{items}[{incomplete}' was not closed properly."
)


Expand Down

0 comments on commit 5913f31

Please sign in to comment.