diff --git a/python/src/trezorlib/client.py b/python/src/trezorlib/client.py index 1cca8339b1..b331059cfc 100644 --- a/python/src/trezorlib/client.py +++ b/python/src/trezorlib/client.py @@ -64,7 +64,7 @@ class TrezorClient: _management_session: Session | None = None _features: messages.Features | None = None _protocol_version: int - _has_setup_pin: bool = False # Should by used only by conftest + _setup_pin: str | None = None # Should by used only by conftest def __init__( self, diff --git a/tests/conftest.py b/tests/conftest.py index 99ed7135e7..ed566eda3b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -392,8 +392,7 @@ def client( needs_backup=setup_params["needs_backup"], # type: ignore no_backup=setup_params["no_backup"], # type: ignore ) - if setup_params["pin"] is not None: - _raw_client._has_setup_pin = True + _raw_client._setup_pin = setup_params["pin"] if request.node.get_closest_marker("experimental"): apply_settings(session, experimental_features=True) @@ -419,12 +418,14 @@ def session( else: derive_cardano = bool(request.node.get_closest_marker("cardano")) passphrase = client.passphrase or "" + if client._setup_pin is not None: + client.use_pin_sequence([client._setup_pin]) session = client.get_session( derive_cardano=derive_cardano, passphrase=passphrase ) try: wrapped_session = SessionDebugWrapper(session) - if client._has_setup_pin: + if client._setup_pin is not None: wrapped_session.lock() yield wrapped_session finally: