Skip to content

Commit

Permalink
Undo workaround changes for python tests parser (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
rquidute authored Feb 22, 2024
1 parent 1fd1429 commit ac5232b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@
KEYWORD_IS_COMISSIONING_INDEX = 0

TC_FUNCTION_PATTERN = re.compile(r"[\S]+_TC_[\S]+")
# This constant is a temporarily fix for TE2
# Issue: https://github.com/project-chip/certification-tool/issues/152
TC_FUNCTION_PATTERN_WORKAROUND = re.compile(r"[\S]+_[\S]+")
TC_TEST_FUNCTION_PATTERN = re.compile(r"test_(?P<title>TC_[\S]+)")
# This constant is a temporarily fix for TE2
# Issue: https://github.com/project-chip/certification-tool/issues/152
TC_TEST_FUNCTION_PATTERN_WORKAROUND = re.compile(r"test_(?P<title>[\S]+_[0-9]+_[0-9]+)")


FunctionDefType = Union[ast.FunctionDef, ast.AsyncFunctionDef]
Expand Down Expand Up @@ -110,13 +104,7 @@ def __test_methods(class_def: ast.ClassDef) -> list[FunctionDefType]:
]
for m in methods:
if isinstance(m.name, str):
# THIS IS A WORKAROUND CODE for TE2
# Some Python tests written in SDK repo are not following the test method
# template, test_TC_[TC_name]
# So this code temporarily code to consider other methods signature as a
# python test script.
# Issue: https://github.com/project-chip/certification-tool/issues/152
if re.match(TC_FUNCTION_PATTERN_WORKAROUND, m.name):
if re.match(TC_FUNCTION_PATTERN, m.name):
all_methods.append(m)

return all_methods
Expand All @@ -138,15 +126,6 @@ def __test_case_names(methods: list[FunctionDefType]) -> list[str]:
if match := re.match(TC_TEST_FUNCTION_PATTERN, m.name):
if name := match["title"]:
test_names.append(name)
# THIS IS A WORKAROUND CODE for TE2
# Some Python tests written in SDK repo are not following the test method
# template, test_TC_[TC_name]
# So this code temporarily code to consider other methods signature as a
# python test script.
# Issue: https://github.com/project-chip/certification-tool/issues/152
elif match := re.match(TC_TEST_FUNCTION_PATTERN_WORKAROUND, m.name):
if name := match["title"]:
test_names.append("TC_" + name)

return test_names

Expand Down Expand Up @@ -192,12 +171,6 @@ def __parse_test_case(
elif desc_method:
python_test_type = PythonTestType.NO_COMMISSIONING

# THIS IS A WORKAROUND CODE for TE2
# The TC_DGGEN_2_4 test case is not following the test method template
if tc_name == "TC_GEN_2_4":
tc_name = "TC_DGGEN_2_4" # spell-checker: disable
tc_desc = "TC_DGGEN_2_4" # spell-checker: disable

return PythonTest(
name=tc_name,
description=tc_desc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,9 @@ async def execute(self) -> None:
f"Missing file path for python test {self.python_test.name}"
)

# THIS IS A WORKAROUND CODE for TE2
# Issue: https://github.com/project-chip/certification-tool/issues/152
test_name = self.python_test.name
if test_name == "TC_DGGEN_2_4": # spell-checker: disable
test_name = "TC_GEN_2_4"
elif test_name in [
"TC_DT_1_1",
"TC_IDM_10_1",
"TC_IDM_11_1",
"TC_DESC_2_2",
]:
test_name = test_name[3:]

command = [
f"{RUNNER_CLASS_PATH} {self.python_test.path.stem}"
f" {self.python_test.class_name} --tests test_{test_name}"
f" {self.python_test.class_name} --tests test_{self.python_test.name}"
]

# Generate the command argument by getting the test_parameters from
Expand Down

0 comments on commit ac5232b

Please sign in to comment.