1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-12 00:10:58 +00:00

tests: better way to shut down test suite when connection to device is lost

This commit is contained in:
matejcik 2020-02-13 16:30:36 +01:00
parent e61b7d28e9
commit 0d3e1b2479

View File

@ -35,8 +35,8 @@ def get_device():
try: try:
transport = get_transport(path) transport = get_transport(path)
return TrezorClientDebugLink(transport, auto_interact=not interact) return TrezorClientDebugLink(transport, auto_interact=not interact)
except Exception: except Exception as e:
pytest.exit("Failed to open debuglink for {}".format(path), 3) raise RuntimeError("Failed to open debuglink for {}".format(path)) from e
else: else:
devices = enumerate_devices() devices = enumerate_devices()
@ -46,7 +46,7 @@ def get_device():
except Exception: except Exception:
pass pass
else: else:
pytest.exit("No debuggable device found", 3) raise RuntimeError("No debuggable device found")
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
@ -73,6 +73,7 @@ def client(request):
try: try:
client = get_device() client = get_device()
except RuntimeError: except RuntimeError:
request.session.shouldstop = "No debuggable Trezor is available"
pytest.fail("No debuggable Trezor is available") pytest.fail("No debuggable Trezor is available")
if request.node.get_closest_marker("skip_t2") and client.features.model == "T": if request.node.get_closest_marker("skip_t2") and client.features.model == "T":