From 842fde455cd4ae7bb96e3b1d2918e4bfbe38d7d5 Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 6 Aug 2019 15:49:56 +0200 Subject: [PATCH] tests: improve debug-trezor detection should (finally) work with a connected production Trezor and an emulator, in which case it should pick the emulator by itself --- tests/device_tests/conftest.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/device_tests/conftest.py b/tests/device_tests/conftest.py index f4f8f5e2f..59036c02c 100644 --- a/tests/device_tests/conftest.py +++ b/tests/device_tests/conftest.py @@ -30,23 +30,23 @@ TREZOR_VERSION = None def get_device(): path = os.environ.get("TREZOR_PATH") + interact = int(os.environ.get("INTERACT", 0)) if path: - transport = get_transport(path) + try: + transport = get_transport(path) + return TrezorClientDebugLink(transport, auto_interact=not interact) + except Exception as e: + raise RuntimeError("Failed to open debuglink for {}".format(path)) from e + else: devices = enumerate_devices() for device in devices: - if hasattr(device, "find_debug"): - transport = device - break + try: + return TrezorClientDebugLink(device, auto_interact=not interact) + except Exception: + pass else: raise RuntimeError("No debuggable device found") - env_interactive = int(os.environ.get("INTERACT", 0)) - try: - return TrezorClientDebugLink(transport, auto_interact=not env_interactive) - except Exception as e: - raise RuntimeError( - "Failed to open debuglink for {}".format(transport.get_path()) - ) from e def device_version():