diff --git a/app/tests/python_tests/test_python_folder.py b/app/tests/python_tests/test_python_folder.py index 2912e8d3..8b113460 100644 --- a/app/tests/python_tests/test_python_folder.py +++ b/app/tests/python_tests/test_python_folder.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# flake8: noqa +# Ignore flake8 check for this file from pathlib import Path from unittest import mock @@ -29,7 +31,8 @@ def test_python_folder_version() -> None: # We mock open to read version_file_content and Path exists to ignore that we're # testing with a fake path with mock.patch( - "test_collections.sdk_tests.support.python_testing.models.python_test_folder.open", + "test_collections.sdk_tests.support.python_testing.models." + "python_test_folder.open", new=mock.mock_open(read_data=version_file_content), ), mock.patch.object(target=Path, attribute="exists", return_value=True) as _: python_test_folder = PythonTestFolder(test_python_path) diff --git a/app/tests/python_tests/test_python_parser.py b/app/tests/python_tests/test_python_parser.py index 645b216f..24167627 100644 --- a/app/tests/python_tests/test_python_parser.py +++ b/app/tests/python_tests/test_python_parser.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# flake8: noqa +# Ignore flake8 check for this file from pathlib import Path from unittest import mock @@ -63,7 +65,8 @@ def test_python_file_parser_throws_pythonparserexception() -> None: file_path = Path("/test/file.py") with mock.patch( - "test_collections.sdk_tests.support.python_testing.models.python_test_parser.open", + "test_collections.sdk_tests.support.python_testing.models.python_test_parser." + "open", new=mock.mock_open(read_data=sample_invalid_python_file_content), ): try: @@ -80,7 +83,8 @@ def test_python_file_parser() -> None: # We mock builtin `open` method to read sample python file content, # to avoid having to load a real file. with mock.patch( - "test_collections.sdk_tests.support.python_testing.models.python_test_parser.open", + "test_collections.sdk_tests.support.python_testing.models.python_test_parser." + "open", new=mock.mock_open(read_data=sample_python_file_content), ) as file_open: test = parse_python_test(file_path) diff --git a/app/tests/python_tests/test_python_script/UnitTest_TC_ACL_1_1_Automated.py b/app/tests/python_tests/test_python_script/UnitTest_TC_ACL_1_1_Automated.py index 00d5a8be..fd8f1972 100644 --- a/app/tests/python_tests/test_python_script/UnitTest_TC_ACL_1_1_Automated.py +++ b/app/tests/python_tests/test_python_script/UnitTest_TC_ACL_1_1_Automated.py @@ -25,9 +25,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# # type: ignore # Ignore mypy type check for this file - +# flake8: noqa +# Ignore flake8 check for this file """ This is just a sample test case that should come from SDK. It should not compile or run. diff --git a/app/tests/python_tests/test_python_test_case.py b/app/tests/python_tests/test_python_test_case.py index f8cb909d..1cc88f4a 100644 --- a/app/tests/python_tests/test_python_test_case.py +++ b/app/tests/python_tests/test_python_test_case.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# flake8: noqa +# Ignore flake8 check for this file from pathlib import Path from typing import Any, Optional, Type from unittest import mock diff --git a/app/tests/python_tests/test_python_test_declarations.py b/app/tests/python_tests/test_python_test_declarations.py index 12d34604..5c797a8b 100644 --- a/app/tests/python_tests/test_python_test_declarations.py +++ b/app/tests/python_tests/test_python_test_declarations.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# flake8: noqa +# Ignore flake8 check for this file from unittest import mock from test_collections.sdk_tests.support.python_testing.models.python_test_models import ( diff --git a/app/tests/python_tests/test_sdk_python_collection.py b/app/tests/python_tests/test_sdk_python_collection.py index 2b695a04..949c653e 100644 --- a/app/tests/python_tests/test_sdk_python_collection.py +++ b/app/tests/python_tests/test_sdk_python_collection.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# flake8: noqa +# Ignore flake8 check for this file from pathlib import Path import pytest diff --git a/test_collections/sdk_tests/support/python_testing/models/python_test_models.py b/test_collections/sdk_tests/support/python_testing/models/python_test_models.py index e639f7d1..51a6860e 100644 --- a/test_collections/sdk_tests/support/python_testing/models/python_test_models.py +++ b/test_collections/sdk_tests/support/python_testing/models/python_test_models.py @@ -17,7 +17,7 @@ from pathlib import Path from typing import Any, Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel ### # This file declares Python test models that are used to parse the Python Test Cases. diff --git a/test_collections/sdk_tests/support/python_testing/models/python_test_parser.py b/test_collections/sdk_tests/support/python_testing/models/python_test_parser.py index 2cef81ee..d1eca07e 100644 --- a/test_collections/sdk_tests/support/python_testing/models/python_test_parser.py +++ b/test_collections/sdk_tests/support/python_testing/models/python_test_parser.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# type: ignore -# Ignore mypy type check for this file import ast from pathlib import Path from typing import List, Tuple @@ -46,7 +44,8 @@ def parse_python_test(path: Path) -> PythonTest: # The file name from path tc_name = path.name.split(".")[0] raise PythonParserException( - f"Test Case {tc_name} does not have methods desc_{tc_name} or steps_{tc_name}" + f"Test Case {tc_name} does not have methods desc_{tc_name} " + f"or steps_{tc_name}" ) test = PythonTest(name=tc_desc, steps=tc_steps, config=tc_config, PICS=tc_pics) @@ -69,7 +68,7 @@ def __extract_tcs_info(path: Path) -> Tuple[str, List[PythonTestStep]]: methods = [m for m in class_.body if isinstance(m, ast.FunctionDef)] for method in methods: if "desc_" in method.name: - tc_desc = method.body[BODY_INDEX].value.value + tc_desc = method.body[BODY_INDEX].value.value # type: ignore elif "steps_" in method.name: tc_steps = __retrieve_steps(method) @@ -78,7 +77,7 @@ def __extract_tcs_info(path: Path) -> Tuple[str, List[PythonTestStep]]: def __retrieve_steps(method: ast.FunctionDef) -> List[PythonTestStep]: python_steps: List[PythonTestStep] = [] - for step in method.body[BODY_INDEX].value.elts: + for step in method.body[BODY_INDEX].value.elts: # type: ignore step_name = step.args[ARG_STEP_DESCRIPTION_INDEX].value arg_is_commissioning = False if ( diff --git a/test_collections/sdk_tests/support/python_testing/models/test_case.py b/test_collections/sdk_tests/support/python_testing/models/test_case.py index a1da6185..5d3a6cb2 100644 --- a/test_collections/sdk_tests/support/python_testing/models/test_case.py +++ b/test_collections/sdk_tests/support/python_testing/models/test_case.py @@ -33,8 +33,8 @@ class PythonTestCase(TestCase): This class provides a class factory that will dynamically declare a new sub-class based on the test-type the Python test is expressing. - The PythonTest will be stored as a class property that will be used at run-time in all - instances of such subclass. + The PythonTest will be stored as a class property that will be used at run-time + in all instances of such subclass. """ python_test: PythonTest @@ -47,7 +47,8 @@ def pics(cls) -> set[str]: @classmethod def default_test_parameters(cls) -> dict[str, Any]: - """Python test config dict, sometimes have a nested dict with type and default value. + """Python test config dict, sometimes have a nested dict with type + and default value. Only defaultValue is used in this case. """ parameters = {}