1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-01 19:38:33 +00:00

TR-tests: add skip_tr pytest mark

This commit is contained in:
grdddj 2023-03-31 12:28:47 +02:00
parent e809dfab73
commit d563ea1cbe
2 changed files with 13 additions and 6 deletions

View File

@ -105,9 +105,11 @@ the following marker:
This marker must be registered in `REGISTERED_MARKERS` file in `tests` folder.
If you wish to run a test only on TT, mark it with `@pytest.mark.skip_t1`.
If the test should only run on T1, mark it with `@pytest.mark.skip_t2`.
You must not use both on the same test.
Tests can be run only for specific models - it is done by disallowing the tests for the other models.
`@pytest.mark.skip_t1`
`@pytest.mark.skip_t2`
`@pytest.mark.skip_tr`
are valid markers to skip current test for T1, TT and TR respectively.
[pytest-random-order]: https://pypi.org/project/pytest-random-order/

View File

@ -157,7 +157,7 @@ def client(
Every test function that requires a client instance will get it from here.
If we can't connect to a debuggable device, the test will fail.
If 'skip_t2' is used and TT is connected, the test is skipped. Vice versa with T1
and 'skip_t1'.
and 'skip_t1'. Same with TR.
The client instance is wiped and preconfigured with "all all all..." mnemonic, no
password and no pin. It is possible to customize this with the `setup_client`
@ -179,6 +179,8 @@ def client(
pytest.skip("Test excluded on Trezor T")
if request.node.get_closest_marker("skip_t1") and _raw_client.features.model == "1":
pytest.skip("Test excluded on Trezor 1")
if request.node.get_closest_marker("skip_tr") and _raw_client.features.model == "R":
pytest.skip("Test excluded on Trezor R")
sd_marker = request.node.get_closest_marker("sd_card")
if sd_marker and not _raw_client.features.sd_card_present:
@ -338,6 +340,7 @@ def pytest_configure(config: "Config") -> None:
# register known markers
config.addinivalue_line("markers", "skip_t1: skip the test on Trezor One")
config.addinivalue_line("markers", "skip_t2: skip the test on Trezor T")
config.addinivalue_line("markers", "skip_tr: skip the test on Trezor R")
config.addinivalue_line(
"markers", "experimental: enable experimental features on Trezor"
)
@ -360,8 +363,10 @@ def pytest_runtest_setup(item: pytest.Item) -> None:
Ensures that altcoin tests are skipped, and that no test is skipped on
both T1 and TT.
"""
if item.get_closest_marker("skip_t1") and item.get_closest_marker("skip_t2"):
raise RuntimeError("Don't skip tests for both trezors!")
if all(
item.get_closest_marker(marker) for marker in ("skip_t1", "skip_t2", "skip_tr")
):
raise RuntimeError("Don't skip tests for all trezor models!")
skip_altcoins = int(os.environ.get("TREZOR_PYTEST_SKIP_ALTCOINS", 0))
if item.get_closest_marker("altcoin") and skip_altcoins: