mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-31 18:40:56 +00:00
tests/device: autodetect Trezor version and skip the appropriate tests automatically
This commit is contained in:
parent
12c58ce3cc
commit
020b298020
34
trezorlib/tests/device_tests/conftest.py
Normal file
34
trezorlib/tests/device_tests/conftest.py
Normal file
@ -0,0 +1,34 @@
|
||||
import pytest
|
||||
|
||||
from . import common
|
||||
from trezorlib.client import TrezorClient
|
||||
|
||||
|
||||
def device_version():
|
||||
device = common.get_device()
|
||||
if not device:
|
||||
raise RuntimeError()
|
||||
client = TrezorClient(device)
|
||||
if client.features.model == "T":
|
||||
return 2
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
||||
try:
|
||||
TREZOR_VERSION = device_version()
|
||||
except:
|
||||
raise
|
||||
TREZOR_VERSION = None
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
'''
|
||||
Called for each test item (class, individual tests).
|
||||
Ensures that 'skip_t2' tests are skipped on T2
|
||||
and 'skip_t1' tests are skipped on T1.
|
||||
'''
|
||||
if item.get_marker("skip_t2") and TREZOR_VERSION == 2:
|
||||
pytest.skip("Test excluded on Trezor T")
|
||||
if item.get_marker("skip_t1") and TREZOR_VERSION == 1:
|
||||
pytest.skip("Test excluded on Trezor 1")
|
Loading…
Reference in New Issue
Block a user