mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
python: more consistent handling of markers in device_tests
also better behavior when no Trezor device is present
This commit is contained in:
parent
9a247eafc0
commit
a0d7a6a667
@ -1,20 +1,3 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
addopts = --pyargs trezorlib.tests.device_tests
|
addopts = --strict --pyargs trezorlib.tests.device_tests
|
||||||
|
xfail_strict = true
|
||||||
markers =
|
|
||||||
capricoin
|
|
||||||
cardano
|
|
||||||
decred
|
|
||||||
eos
|
|
||||||
ethereum
|
|
||||||
komodo
|
|
||||||
lisk
|
|
||||||
monero
|
|
||||||
nem
|
|
||||||
ontology
|
|
||||||
ripple
|
|
||||||
skip_t1
|
|
||||||
skip_t2
|
|
||||||
stellar
|
|
||||||
tezos
|
|
||||||
zcash
|
|
||||||
|
14
python/trezorlib/tests/device_tests/REGISTERED_MARKERS
Normal file
14
python/trezorlib/tests/device_tests/REGISTERED_MARKERS
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
capricoin
|
||||||
|
cardano
|
||||||
|
decred
|
||||||
|
eos
|
||||||
|
ethereum
|
||||||
|
komodo
|
||||||
|
lisk
|
||||||
|
monero
|
||||||
|
nem
|
||||||
|
ontology
|
||||||
|
ripple
|
||||||
|
stellar
|
||||||
|
tezos
|
||||||
|
zcash
|
@ -91,21 +91,25 @@ def setup_client(mnemonic=None, pin="", passphrase=False):
|
|||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
|
# try to figure out trezor version
|
||||||
global TREZOR_VERSION
|
global TREZOR_VERSION
|
||||||
TREZOR_VERSION = device_version()
|
try:
|
||||||
|
TREZOR_VERSION = device_version()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 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")
|
||||||
|
with open(os.path.join(os.path.dirname(__file__), "REGISTERED_MARKERS")) as f:
|
||||||
|
for line in f:
|
||||||
|
config.addinivalue_line("markers", line.strip())
|
||||||
|
|
||||||
|
# enable debug
|
||||||
if config.getoption("verbose"):
|
if config.getoption("verbose"):
|
||||||
log.enable_debug_output()
|
log.enable_debug_output()
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
|
||||||
parser.addoption(
|
|
||||||
"--interactive",
|
|
||||||
action="store_true",
|
|
||||||
help="Wait for user to do interaction manually",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_runtest_setup(item):
|
def pytest_runtest_setup(item):
|
||||||
"""
|
"""
|
||||||
Called for each test item (class, individual tests).
|
Called for each test item (class, individual tests).
|
||||||
@ -114,6 +118,9 @@ def pytest_runtest_setup(item):
|
|||||||
* 'skip_t2' tests are skipped on T2 and 'skip_t1' tests are skipped on T1.
|
* 'skip_t2' tests are skipped on T2 and 'skip_t1' tests are skipped on T1.
|
||||||
* no test should have both skips at the same time
|
* no test should have both skips at the same time
|
||||||
"""
|
"""
|
||||||
|
if TREZOR_VERSION is None:
|
||||||
|
pytest.fail("No debuggable Trezor is available")
|
||||||
|
|
||||||
if item.get_closest_marker("skip_t1") and item.get_closest_marker("skip_t2"):
|
if item.get_closest_marker("skip_t1") and item.get_closest_marker("skip_t2"):
|
||||||
pytest.fail("Don't skip tests for both trezors!")
|
pytest.fail("Don't skip tests for both trezors!")
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ from .conftest import TREZOR_VERSION
|
|||||||
EXPECTED_RESPONSES_NOPIN = [proto.ButtonRequest(), proto.Success(), proto.Features()]
|
EXPECTED_RESPONSES_NOPIN = [proto.ButtonRequest(), proto.Success(), proto.Features()]
|
||||||
EXPECTED_RESPONSES_PIN = [proto.PinMatrixRequest()] + EXPECTED_RESPONSES_NOPIN
|
EXPECTED_RESPONSES_PIN = [proto.PinMatrixRequest()] + EXPECTED_RESPONSES_NOPIN
|
||||||
|
|
||||||
if TREZOR_VERSION >= 2:
|
if TREZOR_VERSION == 1:
|
||||||
EXPECTED_RESPONSES = EXPECTED_RESPONSES_NOPIN
|
|
||||||
else:
|
|
||||||
EXPECTED_RESPONSES = EXPECTED_RESPONSES_PIN
|
EXPECTED_RESPONSES = EXPECTED_RESPONSES_PIN
|
||||||
|
else:
|
||||||
|
EXPECTED_RESPONSES = EXPECTED_RESPONSES_NOPIN
|
||||||
|
|
||||||
|
|
||||||
class TestMsgApplysettings(TrezorTest):
|
class TestMsgApplysettings(TrezorTest):
|
||||||
|
19
setup.cfg
19
setup.cfg
@ -29,20 +29,5 @@ known_standard_library = micropython,ubinascii,ustruct,uctypes,utime,utimeq,trez
|
|||||||
known_third_party = curve25519,ecdsa,hypothesis
|
known_third_party = curve25519,ecdsa,hypothesis
|
||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
markers =
|
addopts = --strict
|
||||||
capricoin
|
xfail_strict = true
|
||||||
cardano
|
|
||||||
decred
|
|
||||||
eos
|
|
||||||
ethereum
|
|
||||||
komodo
|
|
||||||
lisk
|
|
||||||
monero
|
|
||||||
nem
|
|
||||||
ontology
|
|
||||||
ripple
|
|
||||||
skip_t1: skip the test on Trezor One.
|
|
||||||
skip_t2: skip the test on Trezor Model T.
|
|
||||||
stellar
|
|
||||||
tezos
|
|
||||||
zcash
|
|
||||||
|
Loading…
Reference in New Issue
Block a user