diff --git a/trezorlib/tests/device_tests/conftest.py b/trezorlib/tests/device_tests/conftest.py index 6cb9d410a..3e3c732f8 100644 --- a/trezorlib/tests/device_tests/conftest.py +++ b/trezorlib/tests/device_tests/conftest.py @@ -22,13 +22,32 @@ except: TREZOR_VERSION = None +def pytest_addoption(parser): + parser.addini("run_xfail", "List of markers that will run even if marked as xfail", "args", []) + + 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. - ''' + + Performs custom processing, mainly useful for trezor CI testing: + * '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 + * allows to 'runxfail' tests specified by 'run_xfail' in pytest.ini + """ + if item.get_marker("skip_t1") and item.get_marker("skip_t2"): + pytest.fail("Don't skip tests for both trezors!") + 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") + + xfail = item.get_marker("xfail") + run_xfail = any(item.get_marker(marker) for marker in item.config.getini("run_xfail")) + if xfail and run_xfail: + # Deep hack: pytest's private _evalxfail helper determines whether the test should xfail or not. + # The helper caches its result even before this hook runs. + # Here we force-set the result to False, meaning "test does NOT xfail, run as normal" + # IOW, this is basically per-item "--runxfail" + item._evalxfail.result = False diff --git a/trezorlib/tests/device_tests/test_msg_lisk_getaddress.py b/trezorlib/tests/device_tests/test_msg_lisk_getaddress.py index 5ad308fe3..6479c30a4 100644 --- a/trezorlib/tests/device_tests/test_msg_lisk_getaddress.py +++ b/trezorlib/tests/device_tests/test_msg_lisk_getaddress.py @@ -21,6 +21,7 @@ import pytest from .common import TrezorTest +@pytest.mark.lisk @pytest.mark.xfail # drop when trezor-core PR #90 is merged @pytest.mark.skip_t1 class TestMsgLiskGetaddress(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_lisk_getpublickey.py b/trezorlib/tests/device_tests/test_msg_lisk_getpublickey.py index 1683be4ef..37c8759b4 100644 --- a/trezorlib/tests/device_tests/test_msg_lisk_getpublickey.py +++ b/trezorlib/tests/device_tests/test_msg_lisk_getpublickey.py @@ -21,6 +21,7 @@ import pytest from .common import TrezorTest +@pytest.mark.lisk @pytest.mark.xfail # drop when trezor-core PR #90 is merged @pytest.mark.skip_t1 class TestMsgLiskGetPublicKey(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_lisk_signmessage.py b/trezorlib/tests/device_tests/test_msg_lisk_signmessage.py index 022898eb9..f8cca44b4 100644 --- a/trezorlib/tests/device_tests/test_msg_lisk_signmessage.py +++ b/trezorlib/tests/device_tests/test_msg_lisk_signmessage.py @@ -21,6 +21,7 @@ import pytest from .common import TrezorTest +@pytest.mark.lisk @pytest.mark.xfail # drop when trezor-core PR #90 is merged @pytest.mark.skip_t1 class TestMsgLiskSignmessage(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_lisk_signtx.py b/trezorlib/tests/device_tests/test_msg_lisk_signtx.py index a1d36385c..85ad77720 100644 --- a/trezorlib/tests/device_tests/test_msg_lisk_signtx.py +++ b/trezorlib/tests/device_tests/test_msg_lisk_signtx.py @@ -25,6 +25,7 @@ from trezorlib import messages as proto PUBLIC_KEY = unhexlify('eb56d7bbb5e8ea9269405f7a8527fe126023d1db2c973cfac6f760b60ae27294') +@pytest.mark.lisk @pytest.mark.xfail # drop when trezor-core PR #90 is merged @pytest.mark.skip_t1 class TestMsgLiskSignTx(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_lisk_verifymessage.py b/trezorlib/tests/device_tests/test_msg_lisk_verifymessage.py index 46efbb777..28e926ea5 100644 --- a/trezorlib/tests/device_tests/test_msg_lisk_verifymessage.py +++ b/trezorlib/tests/device_tests/test_msg_lisk_verifymessage.py @@ -22,6 +22,7 @@ from .common import TrezorTest from trezorlib import messages as proto +@pytest.mark.lisk @pytest.mark.xfail # drop when trezor-core PR #90 is merged @pytest.mark.skip_t1 class TestMsgLiskVerifymessage(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_nem_getaddress.py b/trezorlib/tests/device_tests/test_msg_nem_getaddress.py index 305be56a0..4a82127dd 100644 --- a/trezorlib/tests/device_tests/test_msg_nem_getaddress.py +++ b/trezorlib/tests/device_tests/test_msg_nem_getaddress.py @@ -18,6 +18,7 @@ from .common import * +@pytest.mark.nem @pytest.mark.xfail # to be removed when nem is merged class TestMsgNEMGetaddress(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics.py b/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics.py index e9f8836b9..4bb369dae 100644 --- a/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics.py +++ b/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics.py @@ -20,6 +20,7 @@ from trezorlib import nem # assertion data from T1 +@pytest.mark.nem @pytest.mark.skip_t2 class TestMsgNEMSignTxMosaics(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py b/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py index 961953398..6068b505d 100644 --- a/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py +++ b/trezorlib/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py @@ -23,6 +23,7 @@ import time # assertion data from T1 +@pytest.mark.nem @pytest.mark.skip_t1 @pytest.mark.xfail # to be removed when nem is merged class TestMsgNEMSignTxMosaics(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_nem_signtx_multisig.py b/trezorlib/tests/device_tests/test_msg_nem_signtx_multisig.py index b41f34ad2..bb6e75a13 100644 --- a/trezorlib/tests/device_tests/test_msg_nem_signtx_multisig.py +++ b/trezorlib/tests/device_tests/test_msg_nem_signtx_multisig.py @@ -21,6 +21,7 @@ from trezorlib import nem # assertion data from T1 +@pytest.mark.nem @pytest.mark.xfail # to be removed when nem is merged class TestMsgNEMSignTxMultisig(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_nem_signtx_others.py b/trezorlib/tests/device_tests/test_msg_nem_signtx_others.py index 50812c1fb..02ae2757d 100644 --- a/trezorlib/tests/device_tests/test_msg_nem_signtx_others.py +++ b/trezorlib/tests/device_tests/test_msg_nem_signtx_others.py @@ -21,6 +21,7 @@ from trezorlib import nem # assertion data from T1 +@pytest.mark.nem @pytest.mark.xfail # to be removed when nem is merged class TestMsgNEMSignTxOther(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_nem_signtx_transfers.py b/trezorlib/tests/device_tests/test_msg_nem_signtx_transfers.py index a6e10baae..456892e9a 100644 --- a/trezorlib/tests/device_tests/test_msg_nem_signtx_transfers.py +++ b/trezorlib/tests/device_tests/test_msg_nem_signtx_transfers.py @@ -22,6 +22,7 @@ from trezorlib import nem # assertion data from T1 +@pytest.mark.nem @pytest.mark.xfail # to be removed when nem is merged class TestMsgNEMSignTx(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_signtx_zcash.py b/trezorlib/tests/device_tests/test_msg_signtx_zcash.py index e4dac926e..de78da648 100644 --- a/trezorlib/tests/device_tests/test_msg_signtx_zcash.py +++ b/trezorlib/tests/device_tests/test_msg_signtx_zcash.py @@ -28,8 +28,11 @@ TxApiZcash = coins.tx_api["Zcash"] TXHASH_93373e = unhexlify('93373e63cc626c4a7d049ad775d6511bb5eba985f142db660c9b9f955c722f5c') -@pytest.mark.skip_t1 -@pytest.mark.skip_t2 +# Zcash reset their testnet, which broke our test because it was not properly cached. +# Then when we tried to revive it, Overwinter happened and now Trezor is incapable of +# processing v3 transactions. So it's difficult to fix the test until we support v3. +@pytest.mark.zcash +@pytest.mark.xfail(reason="Zcash support is botched due to Overwinter") class TestMsgSigntxZcash(TrezorTest): def test_one_one_fee(self): diff --git a/trezorlib/tests/device_tests/test_msg_stellar_get_public_key.py b/trezorlib/tests/device_tests/test_msg_stellar_get_public_key.py index 85c1d8377..cd7cec279 100644 --- a/trezorlib/tests/device_tests/test_msg_stellar_get_public_key.py +++ b/trezorlib/tests/device_tests/test_msg_stellar_get_public_key.py @@ -19,6 +19,7 @@ from trezorlib import stellar import pytest +@pytest.mark.stellar @pytest.mark.xfail(TREZOR_VERSION == 2, reason="T2 support is not yet finished") class TestMsgStellarGetPublicKey(TrezorTest): diff --git a/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py b/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py index 4ffe6af3d..dfef8509e 100644 --- a/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py +++ b/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py @@ -25,6 +25,7 @@ from trezorlib import messages as proto import pytest +@pytest.mark.stellar @pytest.mark.xfail(TREZOR_VERSION == 2, reason="T2 support is not yet finished") class TestMsgStellarSignTransaction(TrezorTest):