Skip to content

Commit c98bc77

Browse files
cecilleaustina-csa
authored andcommitted
Python documentation: Add a bit more detail on how to run locally (project-chip#33644)
1 parent 1a1dbaa commit c98bc77

File tree

1 file changed

+55
-7
lines changed

1 file changed

+55
-7
lines changed

docs/testing/python.md

+55-7
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,64 @@ second_ctrl = fa.new_fabric_admin.NewController(nodeId=node_id)
480480

481481
# Running tests locally
482482

483-
You can run the python script as-is for local testing against an already-running
484-
DUT
483+
## Setup
485484

486-
`./scripts/tests/run_python_test.py` is a convenient script to fire up an
487-
example DUT on the host, with factory reset support
485+
The scripts require the python wheel to be compiled and installed before
486+
running. To compile and install the wheel, do the following:
488487

489-
`./scripts/tests/run_python_test.py --factoryreset --app <your_app> --app-args "whatever" --script <your_script> --script-args "whatever"`
488+
First activate the matter environment using either
489+
490+
```
491+
. ./scripts/bootstrap.sh
492+
```
493+
494+
or
495+
496+
```
497+
. ./scripts/activate.sh
498+
```
499+
500+
bootstrap.sh should be used for for the first setup, activate.sh may be used for
501+
subsequent setups as it is faster.
502+
503+
Next build the python wheels and create / activate a venv (called `py` here, but
504+
any name may be used)
505+
506+
```
507+
./scripts/build_python.sh -i py
508+
source py/bin/activate
509+
```
510+
511+
## Running tests
490512

491-
Note that devices must be commissioned by the python test harness to run tests.
492-
chip-tool and the python test harness DO NOT share a fabric.
513+
- Note that devices must be commissioned by the python test harness to run
514+
tests. chip-tool and the python test harness DO NOT share a fabric.
515+
516+
Once the wheel is installed, you can run the python script as a normal python
517+
file for local testing against an already-running DUT. This can be an example
518+
app on the host computer (running in a different terminal), or a separate device
519+
that will be commissioned either over BLE or WiFi.
520+
521+
For example, to run the TC-ACE-1.2 tests against an un-commissioned DUT:
522+
523+
```
524+
python3 src/python_testing/TC_ACE_1_2.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00
525+
```
526+
527+
Some tests require additional arguments (ex. PIXITs or configuration variables
528+
for the CI). These arguments can be passed as sets of key-value pairs using the
529+
`--<type>-arg` command line arguments. For example
530+
531+
```
532+
--int-arg PIXIT.ACE.APPENDPOINT:1 PIXIT.ACE.APPDEVTYPEID:0x0100 --string-arg PIXIT.ACE.APPCLUSTER:OnOff PIXIT.ACE.APPATTRIBUTE:OnOff
533+
```
534+
535+
## Local host app testing
536+
537+
`./scripts/tests/run_python_test.py` is a convenient script that starts an
538+
example DUT on the host and includes factory reset support
539+
540+
`./scripts/tests/run_python_test.py --factoryreset --app <your_app> --app-args "whatever" --script <your_script> --script-args "whatever"`
493541

494542
# Running tests in CI
495543

0 commit comments

Comments
 (0)