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
1616from re import compile
1717from typing import List
1818
19- from .ReaderConfig import ReaderConfig
20- from .ReaderConfig import TestCaseData
21- from .search import search_variable
22-
2319from robot .libraries .BuiltIn import BuiltIn # type: ignore
2420from robot .utils import DotDict # type: ignore
2521
22+ from .ReaderConfig import ReaderConfig , TestCaseData
23+ from .search import search_variable
2624
2725built_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