diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-02-23 16:03:16 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-02-23 16:03:16 +0100 |
commit | d5486ba77235a874245fbee07a75cea89fa59ea2 (patch) | |
tree | 7f2df53da4c018fbfa6ec57809bcd2fcefaf0624 /unittest/conftest.py | |
parent | 102ee60cd8ee9e5ce263de1d4a775acf29f37fbc (diff) | |
parent | a262472826830ea0a98a4da2fa8f665d359b8789 (diff) | |
download | libnitrokey-d5486ba77235a874245fbee07a75cea89fa59ea2.tar.gz libnitrokey-d5486ba77235a874245fbee07a75cea89fa59ea2.tar.bz2 |
Merge branch 'wip-support_storage_v0.51'
Support for functionality added in v0.49/v0.51
Diffstat (limited to 'unittest/conftest.py')
-rw-r--r-- | unittest/conftest.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/unittest/conftest.py b/unittest/conftest.py index 8f386e0..49f1502 100644 --- a/unittest/conftest.py +++ b/unittest/conftest.py @@ -34,7 +34,7 @@ def skip_if_device_version_lower_than(allowed_devices): @pytest.fixture(scope="module") -def C(request): +def C(request=None): fp = '../NK_C_API.h' declarations = [] @@ -77,15 +77,17 @@ def C(request): print("No library file found") sys.exit(1) - C.NK_set_debug(False) + C.NK_set_debug_level(int(os.environ.get('LIBNK_DEBUG', 2))) + nk_login = C.NK_login_auto() if nk_login != 1: print('No devices detected!') assert nk_login != 0 # returns 0 if not connected or wrong model or 1 when connected global device_type - firmware_version = C.NK_get_major_firmware_version() + firmware_version = C.NK_get_minor_firmware_version() model = 'P' if firmware_version in [7,8] else 'S' device_type = (model, firmware_version) + print('Connected device: {} {}'.format(model, firmware_version)) # assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK # assert C.NK_user_authenticate(DefaultPasswords.USER, DefaultPasswords.USER_TEMP) == DeviceErrorCode.STATUS_OK @@ -97,8 +99,9 @@ def C(request): C.NK_logout() print('Finished') - request.addfinalizer(fin) + if request: + request.addfinalizer(fin) # C.NK_set_debug(True) - C.NK_set_debug_level(3) + C.NK_set_debug_level(int(os.environ.get('LIBNK_DEBUG', 3))) return C |