mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-21 12:02:19 +00:00
device_tests: smarter device selection
skips bridge, dies somewhat more cleanly when no device found
This commit is contained in:
parent
abf0e82d80
commit
e2d45397d4
@ -18,14 +18,23 @@ import functools
|
|||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib.transport import get_transport
|
from trezorlib.transport import get_transport, enumerate_devices
|
||||||
from trezorlib.client import TrezorClient, TrezorClientDebugLink
|
from trezorlib.client import TrezorClient, TrezorClientDebugLink
|
||||||
from trezorlib import log, coins
|
from trezorlib import log, coins
|
||||||
|
|
||||||
|
TREZOR_VERSION = None
|
||||||
|
|
||||||
|
|
||||||
def get_device():
|
def get_device():
|
||||||
path = os.environ.get("TREZOR_PATH")
|
path = os.environ.get("TREZOR_PATH")
|
||||||
return get_transport(path)
|
if path:
|
||||||
|
return get_transport(path)
|
||||||
|
else:
|
||||||
|
devices = enumerate_devices()
|
||||||
|
for device in devices:
|
||||||
|
if hasattr(device, "find_debug"):
|
||||||
|
return device
|
||||||
|
raise RuntimeError("No debuggable device found")
|
||||||
|
|
||||||
|
|
||||||
def device_version():
|
def device_version():
|
||||||
@ -39,9 +48,6 @@ def device_version():
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
TREZOR_VERSION = device_version()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def client():
|
def client():
|
||||||
wirelink = get_device()
|
wirelink = get_device()
|
||||||
@ -86,6 +92,9 @@ def setup_client(mnemonic=None, pin="", passphrase=False):
|
|||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
|
global TREZOR_VERSION
|
||||||
|
TREZOR_VERSION = device_version()
|
||||||
|
|
||||||
if config.getoption("verbose"):
|
if config.getoption("verbose"):
|
||||||
log.enable_debug_output()
|
log.enable_debug_output()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user