From 9537923335423e3c69faf5733f3251fdcb38a7ff Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 8 Dec 2022 18:33:45 +0100 Subject: [PATCH 1/2] Skip integration tests, when device is not connected Skip tests depending on the connected device. Currently all of them. --- pynitrokey/conftest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pynitrokey/conftest.py b/pynitrokey/conftest.py index f586b1a7..5876537c 100644 --- a/pynitrokey/conftest.py +++ b/pynitrokey/conftest.py @@ -7,6 +7,7 @@ import secrets from _pytest.fixtures import FixtureRequest +from pynitrokey.cli import CliException from pynitrokey.cli.nk3 import Context from pynitrokey.nk3.otp_app import Instruction, OTPApp @@ -46,7 +47,11 @@ def corpus_func(request: FixtureRequest): @pytest.fixture(scope="session") def dev(): ctx = Context(None) - return ctx.connect_device() + try: + return ctx.connect_device() + except CliException as e: + if "No Nitrokey 3 device found" in str(e): + pytest.skip(f"Cannot connect to the Nitrokey 3 device. Error: {e}") @pytest.fixture(scope="function") From f42055a032d3528d02fd858e46bb5c7233a376f7 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 8 Dec 2022 18:34:25 +0100 Subject: [PATCH 2/2] Help string correction --- pynitrokey/cli/start.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pynitrokey/cli/start.py b/pynitrokey/cli/start.py index 70d191e0..1fddd0e4 100644 --- a/pynitrokey/cli/start.py +++ b/pynitrokey/cli/start.py @@ -108,7 +108,7 @@ def set_identity(identity, force_restart): This could be replaced with: - gpg-connect-agent "SCD APDU 00 85 00 0 + gpg-connect-agent "SCD APDU 00 85 00 0" """ if not identity.isdigit(): local_critical("identity number must be a digit")