Skip to content

Commit be50356

Browse files
committed
fixed Robot Framework 6.1 compatibility
1 parent 91d9d55 commit be50356

21 files changed

+252
-191
lines changed

atest/TestCases/Tags/foo_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def _read_file_to_data_table(self):
1010
test_data = []
1111
flipflop = True
1212
for i in range(6):
13-
args = {'${fooarg}': i}
13+
args = {"${fooarg}": i}
1414
tags = ["included"]
1515
if flipflop:
1616
tags = ["filtered"]

atest/TestCases/custom_reader/custom_reader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
from DataDriver.AbstractReaderClass import (
1717
AbstractReaderClass,
1818
) # inherit class from AbstractReaderClass
19-
from DataDriver.ReaderConfig import TestCaseData # return list of TestCaseData to DataDriver
19+
from DataDriver.ReaderConfig import (
20+
TestCaseData,
21+
) # return list of TestCaseData to DataDriver
2022

2123

2224
class custom_reader(AbstractReaderClass):

create_readme.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from DataDriver import DataDriver
21
from inspect import getdoc
2+
from pathlib import Path
3+
4+
from DataDriver import DataDriver
35

4-
with open("Readme.rst", "w", encoding="utf-8") as readme:
6+
with Path("Readme.rst").open("w", encoding="utf-8") as readme:
57
doc_string = getdoc(DataDriver)
68
readme.write(str(doc_string).replace("\\", "\\\\").replace("\\\\*", "\\*"))

pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[tool.black]
2+
target-version = ['py38']
3+
line-length = 100
4+
5+
[tool.mypy]
6+
exclude = [
7+
'.*__init__\.py$',
8+
'^build.*'
9+
]
10+
11+
[tool.ruff]
12+
unfixable = []
13+
exclude = [
14+
"atest",
15+
"example"
16+
]
17+
ignore = [
18+
"B008", # do not perform function calls in argument defaults
19+
"E501", # line too long
20+
"N815", # mixedCase variable in class scope
21+
"N803", # argument name should be lowercase
22+
"N806", # variable in function should be lowercase
23+
"N812", # lowercase imported as non lowercase
24+
"W605", # invalid escape sequence would destroy docs
25+
"RUF002", # Docstring contains ambiguous
26+
"N801", # Class name `xxx` should use CapWords convention
27+
"PLR0913", # Too many arguments to function call
28+
"N999", # Invalid module name:
29+
]
30+
target-version = "py37"
31+
select = [
32+
"E",
33+
"F",
34+
"W",
35+
"C90",
36+
"I",
37+
"N",
38+
"B",
39+
"PYI",
40+
"PL",
41+
"PTH",
42+
"UP",
43+
"A",
44+
"C4",
45+
"DTZ",
46+
"ISC",
47+
"ICN",
48+
"INP",
49+
"PIE",
50+
"T20",
51+
"PYI",
52+
"PT",
53+
"RSE",
54+
"RET",
55+
"SIM",
56+
"RUF"
57+
]

setup.cfg

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[metadata]
2+
name = robotframework-datadriver
3+
version = attr: src.DataDriver.DataDriver.__version__
4+
author = René Rohner(Snooz82)
5+
author_email = snooz@posteo.de
6+
description = A library for Data-Driven Testing.
7+
long_description = file: Readme.rst
8+
long_description_content_type = text/x-rst
9+
url = https://github.com/Snooz82/robotframework-datadriver
10+
classifiers =
11+
Programming Language :: Python :: 3
12+
Programming Language :: Python :: 3.6
13+
Programming Language :: Python :: 3.7
14+
License :: OSI Approved :: Apache Software License
15+
Operating System :: OS Independent
16+
Topic :: Software Development :: Testing
17+
Topic :: Software Development :: Testing :: Acceptance
18+
Framework :: Robot Framework
19+
20+
[options]
21+
packages = find:
22+
package_dir =
23+
= src
24+
install_requires =
25+
robotframework >= 4.0.2
26+
docutils
27+
Pygments
28+
python_requires = >=3.6.15
29+
30+
[options.extras_require]
31+
xls =
32+
pandas
33+
xlrd >= 1.2.0
34+
openpyxl
35+
36+
[options.packages.find]
37+
where = src

setup.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,3 @@
1-
from setuptools import setup
2-
from setuptools import find_packages
3-
import re
4-
from os.path import abspath, dirname, join
1+
from setuptools import setup # type: ignore
52

6-
CURDIR = dirname(abspath(__file__))
7-
8-
with open("Readme.rst", "r", encoding="utf-8") as fh:
9-
long_description = fh.read()
10-
11-
with open(join(CURDIR, "src", "DataDriver", "DataDriver.py"), encoding="utf-8") as f:
12-
VERSION = re.search('\n__version__ = "(.*)"', f.read()).group(1)
13-
14-
setup(
15-
name="robotframework-datadriver",
16-
version=VERSION,
17-
author="René Rohner(Snooz82)",
18-
author_email="snooz@posteo.de",
19-
description="A library for Data-Driven Testing.",
20-
long_description=long_description,
21-
long_description_content_type="text/x-rst",
22-
url="https://github.com/Snooz82/robotframework-datadriver",
23-
package_dir={"": "src"},
24-
packages=find_packages("src"),
25-
classifiers=[
26-
"Programming Language :: Python :: 3",
27-
"Programming Language :: Python :: 3.6",
28-
"Programming Language :: Python :: 3.7",
29-
"License :: OSI Approved :: Apache Software License",
30-
"Operating System :: OS Independent",
31-
"Topic :: Software Development :: Testing",
32-
"Topic :: Software Development :: Testing :: Acceptance",
33-
"Framework :: Robot Framework",
34-
],
35-
install_requires=["robotframework >= 4.0.2", "docutils", "Pygments"],
36-
extras_require={"xls": ["pandas", "xlrd >= 1.2.0", "openpyxl"]},
37-
python_requires=">=3.6.15",
38-
)
3+
setup()

src/DataDriver/AbstractReaderClass.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from abc import ABC
15+
from abc import ABC, abstractmethod
1616
from re import compile
1717
from typing import List
1818

19-
from .ReaderConfig import ReaderConfig
20-
from .ReaderConfig import TestCaseData
21-
from .search import search_variable
22-
2319
from robot.libraries.BuiltIn import BuiltIn # type: ignore
2420
from robot.utils import DotDict # type: ignore
2521

22+
from .ReaderConfig import ReaderConfig, TestCaseData
23+
from .search import search_variable
2624

2725
built_in = BuiltIn()
2826

@@ -48,11 +46,11 @@ def __init__(self, reader_config: ReaderConfig):
4846
setattr(self, key, value)
4947

5048
self.test_case_column_id = None
51-
self.arguments_column_ids: List = list()
49+
self.arguments_column_ids: List = []
5250
self.tags_column_id = None
5351
self.documentation_column_id = None
54-
self.header: List = list()
55-
self.data_table: List = list()
52+
self.header: List = []
53+
self.data_table: List[TestCaseData] = []
5654

5755
self.TESTCASE_TABLE_NAME = ReaderConfig.TEST_CASE_TABLE_NAME
5856
self.TEST_CASE_TABLE_PATTERN = compile(r"(?i)^(\*+\s*test ?cases?[\s*].*)")
@@ -62,10 +60,9 @@ def __init__(self, reader_config: ReaderConfig):
6260
self.DOCUMENTATION_PATTERN = compile(r"(?i)(\[)(documentation)(\])")
6361
self.LIT_EVAL_PATTERN = compile(r"e\{(.+)\}")
6462

65-
def get_data_from_source(self):
66-
raise NotImplementedError(
67-
"This method should be implemented and return self.data_table to DataDriver..."
68-
)
63+
@abstractmethod
64+
def get_data_from_source(self) -> List[TestCaseData]:
65+
"""This method must be implemented and return self.data_table ( a List[TestCaseData] )."""
6966

7067
def _is_test_case_header(self, header_string: str):
7168
return self.TEST_CASE_TABLE_PATTERN.fullmatch(
@@ -84,14 +81,14 @@ def _is_documentation(self, header_string: str):
8481
def _analyse_header(self, header_cells):
8582
self.header = header_cells
8683
for cell_index, cell in enumerate(self.header):
87-
cell = cell.strip()
88-
if self._is_test_case_header(cell):
84+
naked_cell = cell.strip()
85+
if self._is_test_case_header(naked_cell):
8986
self.test_case_column_id = cell_index
90-
elif self._is_variable(cell):
87+
elif self._is_variable(naked_cell):
9188
self.arguments_column_ids.append(cell_index)
92-
elif self._is_tags(cell):
89+
elif self._is_tags(naked_cell):
9390
self.tags_column_id = cell_index
94-
elif self._is_documentation(cell):
91+
elif self._is_documentation(naked_cell):
9592
self.documentation_column_id = cell_index
9693

9794
def _read_data_from_table(self, row):
@@ -157,8 +154,7 @@ def _update_argument_dict(self, arguments, base, items, value):
157154
selected_key = selected_key[key]
158155
selected_key[items[-1]] = built_in.replace_variables(value)
159156
return argument
160-
else:
161-
raise TypeError(f"{self._as_var(base)} is defined with a wrong type. Not defaultdict.")
157+
raise TypeError(f"{self._as_var(base)} is defined with a wrong type. Not defaultdict.")
162158

163159
def _as_var(self, base):
164160
return f"${{{base}}}"

0 commit comments

Comments
 (0)