Repository: nitrokey/pynitrokey
Issue: Improve error message for provisioner test

After quite a while I was playing around with my Nitrokey 3A NFC again and ran the test suite `nitropy nk3 test --all` and it failed.
One error message was particularly unhelpful:
`[4/5]	provisioner  	Firmware mode             	FAILURE  	Failed to establish context: Service not available. (0x8010001D)`
1. I don't understand what is being tested.
2. It does not tell me which service is not available.
3. It give me no clue on how to resolve the issue.
4. There is no documentation available anywhere.

The only way I happened to stumble upon a possible solution is because the competitor Yubikey used to throw a very similar error message that is just as bad and I could find a solution for that https://github.com/Yubico/yubioath-flutter/issues/78.

After issuing a `systemctl start pcscd.service` (pcsc stuff was already installed, perhaps I ran into this before and forgot) I still get a test failure but with a different message and I still do not know whether this is to be expected.
`[4/5]	provisioner  	Firmware mode             	FAILURE  	No smartcard with UUID <UUID> found`

Please improve the error messages to avoid this kind of confusion.

```
$ nitropy nk3 version               
Command line tool to interact with Nitrokey devices 0.4.33
v1.2.2
```

Changed files:
pynitrokey/cli/nk3/test.py

diff --git a/pynitrokey/cli/nk3/test.py b/pynitrokey/cli/nk3/test.py
index 5246018..f6b0bad 100644
--- a/pynitrokey/cli/nk3/test.py
+++ b/pynitrokey/cli/nk3/test.py
@@ -33,7 +33,7 @@ TEST_CASES = []
 AID_ADMIN = [0xA0, 0x00, 0x00, 0x08, 0x47, 0x00, 0x00, 0x00, 0x01]
 AID_PROVISIONER = [0xA0, 0x00, 0x00, 0x08, 0x47, 0x01, 0x00, 0x00, 0x01]
 
-DEFAULT_EXCLUDES = ["bootloader"]
+DEFAULT_EXCLUDES = ["bootloader", "provisioner"]
 
 
 ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
@@ -187,10 +187,15 @@ def test_bootloader_configuration(
         return TestResult(TestStatus.FAILURE, "bootloader not locked")
 
 
-try:
-    from smartcard import System
-    from smartcard.CardConnection import CardConnection
-    from smartcard.Exceptions import NoCardException
+@test_case("provisioner", "Firmware mode")
+def test_firmware_mode(ctx: TestContext, device: Nitrokey3Base) -> TestResult:
+    try:
+        from smartcard import System
+        from smartcard.CardConnection import CardConnection
+        from smartcard.Exceptions import NoCardException
+    except ImportError:
+        logger.debug("pcsc feature is deactivated, skipping firmware mode test")
+        return TestResult(TestStatus.SKIPPED, "pcsc feature is deactivated")
 
     def find_smartcard(uuid: Uuid) -> CardConnection:
         for reader in System.readers():
@@ -218,20 +223,14 @@ try:
         _, sw1, sw2 = conn.transmit(apdu)
         return (sw1, sw2) == (0x90, 0x00)
 
-    @test_case("provisioner", "Firmware mode")
-    def test_firmware_mode(ctx: TestContext, device: Nitrokey3Base) -> TestResult:
-        uuid = device.uuid()
-        if not uuid:
-            return TestResult(TestStatus.SKIPPED, "no UUID")
-        conn = find_smartcard(uuid)
-        if select(conn, AID_PROVISIONER):
-            return TestResult(TestStatus.FAILURE, "provisioner application active")
-        else:
-            return TestResult(TestStatus.SUCCESS)
-
-except ImportError:
-    logger.debug("pcsc feature is deactivated, skipping firmware mode test")
-    pass
+    uuid = device.uuid()
+    if not uuid:
+        return TestResult(TestStatus.SKIPPED, "no UUID")
+    conn = find_smartcard(uuid)
+    if select(conn, AID_PROVISIONER):
+        return TestResult(TestStatus.FAILURE, "provisioner application active")
+    else:
+        return TestResult(TestStatus.SUCCESS)
 
 
 @test_case("fido2", "FIDO2")