Skip to content

Commit

Permalink
Merge branch '294-mark-integration-tests'
Browse files Browse the repository at this point in the history
Skip tests requiring device, when it is not connected, instead of
reporting an error

Fixes #294
  • Loading branch information
szszszsz committed Dec 8, 2022
2 parents 752df92 + f42055a commit 4f86272
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pynitrokey/cli/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def set_identity(identity, force_restart):
This could be replaced with:
gpg-connect-agent "SCD APDU 00 85 00 0<IDENTITY>
gpg-connect-agent "SCD APDU 00 85 00 0<IDENTITY>"
"""
if not identity.isdigit():
local_critical("identity number must be a digit")
Expand Down
7 changes: 6 additions & 1 deletion pynitrokey/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 4f86272

Please sign in to comment.