mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 23:38:09 +00:00
testing: configure pytest.ini and update testing documentation
as per https://github.com/trezor/python-trezor/pull/263
This commit is contained in:
parent
df967821e7
commit
003d77b209
@ -48,16 +48,37 @@ export TREZOR_PATH="udp:127.0.0.1:21324"
|
|||||||
```
|
```
|
||||||
(You can find other devices with `trezorctl list`.)
|
(You can find other devices with `trezorctl list`.)
|
||||||
|
|
||||||
Now you can run the test suite with:
|
Now you can run the test suite, either from `python-trezor` or `trezor-core` root directory:
|
||||||
```sh
|
```sh
|
||||||
pytest
|
pytest
|
||||||
```
|
```
|
||||||
|
Or from anywhere else:
|
||||||
|
```sh
|
||||||
|
pytest --pyargs trezorlib.tests.device_tests # this works from other locations
|
||||||
|
```
|
||||||
|
|
||||||
You can place your own tests in `trezorlib/tests/device_tests`. See test style guide (TODO).
|
You can place your own tests in `trezorlib/tests/device_tests`. See test style guide (TODO).
|
||||||
|
|
||||||
If you only want to run a particular test, pick it with `-k <keyword>`:
|
If you only want to run a particular test, pick it with `-k <keyword>` or `-m <marker>`:
|
||||||
```sh
|
```sh
|
||||||
pytest -k nem # only runs tests that have "nem" in the name
|
pytest -k nem # only runs tests that have "nem" in the name
|
||||||
|
pytest -m stellar # only runs tests marked with @pytest.mark.stellar
|
||||||
```
|
```
|
||||||
If you have tests marked `xfail` (expected to fail) but you want to run them as usual, run `pytest --runxfail`
|
|
||||||
If you want to see debugging information and protocol dumps, run with `-v`.
|
If you want to see debugging information and protocol dumps, run with `-v`.
|
||||||
|
|
||||||
|
### 3. Submitting tests for new features
|
||||||
|
|
||||||
|
When you're happy with your tests, follow these steps:
|
||||||
|
|
||||||
|
1. Mark each of your tests with the name of your feature. E.g., `@pytest.mark.ultracoin2000`.
|
||||||
|
2. Also mark each of your tests with `@pytest.mark.xfail`. That means that the test is expected to fail.
|
||||||
|
If you want to run that test as usual, run `pytest --runxfail`
|
||||||
|
3. Submit a PR to `python-trezor`, containing these tests.
|
||||||
|
4. Edit the file `trezor-core/pytest.ini`, and add your marker to the `run_xfail` item:
|
||||||
|
```
|
||||||
|
run_xfail = lisk nem ultracoin2000
|
||||||
|
```
|
||||||
|
This will cause your PR to re-enable the `xfail`ed tests. That way we will see whether your feature actually implements what it claims.
|
||||||
|
5. Submit a PR to `trezor-core`.
|
||||||
|
6. Optionally, if you like to be extra nice: after both your PRs are accepted, submit a new one to `python-trezor` that removes the `xfail` markers, and one to `trezor-core` that removes the `run_xfail` entry.
|
||||||
|
6
pytest.ini
Normal file
6
pytest.ini
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[pytest]
|
||||||
|
addopts = --pyargs trezorlib.tests.device_tests
|
||||||
|
xfail_strict = true
|
||||||
|
|
||||||
|
# List of markers that run as if not xfailed. See docs/testing.md for details
|
||||||
|
# run_xfail = stellar lisk nem
|
@ -14,7 +14,7 @@ export TREZOR_PATH=udp:127.0.0.1:21324
|
|||||||
# run tests
|
# run tests
|
||||||
cd ../tests
|
cd ../tests
|
||||||
error=0
|
error=0
|
||||||
if ! pytest -k 'not skip_t2' --pyargs trezorlib.tests.device_tests "$@"; then
|
if ! pytest -c ../pytest.ini "$@"; then
|
||||||
error=1
|
error=1
|
||||||
fi
|
fi
|
||||||
kill $upy_pid
|
kill $upy_pid
|
||||||
|
Loading…
Reference in New Issue
Block a user