Skip to content

Commit 6e750ec

Browse files
authored
Python testing hello example: Fix for TH expectations (#31688)
The TH expects tests to appear in a certain way to be properly picked up and parsed. Add instructions in the hello test and change the example names to match the expectations.
1 parent 53b2d4b commit 6e750ec

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/python_testing/hello_external_runner.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ def main():
137137
app_process = subprocess.Popen([app_cmd], stdout=sys.stdout, stderr=sys.stderr, bufsize=0)
138138

139139
commission()
140-
one_test('test_failure_on_wrong_endpoint')
141-
one_test('test_names_as_expected')
142-
one_test('test_pics')
140+
one_test('test_TC_NAMES_2_1')
141+
one_test('test_TC_ENDPOINT_2_1')
142+
one_test('test_TC_PICSTEST_2_1')
143143

144144
app_process.send_signal(signal.SIGINT.value)
145145
app_process.wait()

src/python_testing/hello_test.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ class HelloTest(MatterBaseTest):
2727
# This example test does not include the step_ and desc_ markers
2828
# The MatterBaseTest will assume a single step and create a description
2929
# based on the test name
30+
# To work in the Test harness, all tests should be named as
31+
# TC_PICSCODE_#_#, (substituting the appropriate pics codes and numbers for the test)
3032
@async_test_body
31-
async def test_names_as_expected(self):
33+
async def test_TC_NAMES_2_1(self):
3234
dev_ctrl = self.default_controller
3335
vendor_name = await self.read_single_attribute(
3436
dev_ctrl,
@@ -44,17 +46,19 @@ async def test_names_as_expected(self):
4446
# for the test, then use self.step(#) to indicate how the test proceeds through the test plan.
4547
# Support for keeping the TH up to date is built into MatterBaseTest when you use the step()
4648
# function.
47-
def steps_failure_on_wrong_endpoint(self) -> list[TestStep]:
49+
# If the device needs to be commissioned before running the test, ensure the first step in
50+
# this function is marked is_commissioning=True.
51+
def steps_TC_ENDPOINT_2_1(self) -> list[TestStep]:
4852
steps = [TestStep(1, "Commissioning, already done", is_commissioning=True),
4953
TestStep(2, "Read ProductName on endpoint 9999"),
5054
]
5155
return steps
5256

53-
def desc_failure_on_wrong_endpoint(self) -> str:
57+
def desc_TC_ENDPOINT_2_1(self) -> str:
5458
return '#.#.#. [TC-HELLO-x.x] Test Failure On Wrong Endpoint'
5559

5660
@async_test_body
57-
async def test_failure_on_wrong_endpoint(self):
61+
async def test_TC_ENDPOINT_2_1(self):
5862
self.step(1) # Commissioning
5963

6064
self.step(2)
@@ -68,19 +72,19 @@ async def test_failure_on_wrong_endpoint(self):
6872
asserts.assert_true(isinstance(result, Clusters.Attribute.ValueDecodeFailure), "Should fail to read on endpoint 9999")
6973
asserts.assert_equal(result.Reason.status, Status.UnsupportedEndpoint, "Failure reason should be UnsupportedEndpoint")
7074

71-
def steps_pics(self) -> list[TestStep]:
75+
def steps_TC_PICSTEST_2_1(self) -> list[TestStep]:
7276
steps = [TestStep(1, "Commissioning, already done", is_commissioning=True),
7377
TestStep(2, "Skip this step based on pics"),
7478
TestStep(3, "Run this step"),
7579
TestStep(4, "Always skip this step")
7680
]
7781
return steps
7882

79-
def desc_pics(self) -> str:
83+
def desc_TC_PICSTEST_2_1(self) -> str:
8084
return "#.#.#. [TC-HELLO-x.x] Test pics"
8185

8286
@async_test_body
83-
async def test_pics(self):
87+
async def test_TC_PICSTEST_2_1(self):
8488
self.step(1) # commissioning
8589
print('This should be run')
8690

0 commit comments

Comments
 (0)