Skip to content

Commit ee56294

Browse files
committed
Updates
Signed-off-by: Vlad Gheorghiu <[email protected]>
1 parent 1e589b2 commit ee56294

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

oqs/oqs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _countdown(seconds):
4545
def _load_shared_obj(name, additional_searching_paths=None):
4646
"""Attempts to load shared library."""
4747
paths = []
48-
dll = ct.windll if platform.system() == "Windows" else ct.cdll
48+
dll = ct.windll if platform.system() == "Windows" else ct.cdll # type: ignore
4949

5050
# Search additional path, if any
5151
if additional_searching_paths:
@@ -152,7 +152,7 @@ def native():
152152
def oqs_version():
153153
"""liboqs version string."""
154154
native().OQS_version.restype = ct.c_char_p
155-
return ct.c_char_p(native().OQS_version()).value.decode("UTF-8")
155+
return ct.c_char_p(native().OQS_version()).value.decode() # type: ignore
156156

157157

158158
# Warn the user if the liboqs version differs from liboqs-python version
@@ -252,7 +252,7 @@ def __init__(self, alg_name, secret_key=None):
252252
def __enter__(self):
253253
return self
254254

255-
def __exit__(self, ctx_type, ctx_value, ctx_traceback):
255+
def __exit__(self, _ctx_type, _ctx_value, _ctx_traceback):
256256
self.free()
257257

258258
def generate_keypair(self):
@@ -418,7 +418,7 @@ def __init__(self, alg_name, secret_key=None):
418418
def __enter__(self):
419419
return self
420420

421-
def __exit__(self, ctx_type, ctx_value, ctx_traceback):
421+
def __exit__(self, _ctx_type, _ctx_value, _ctx_traceback):
422422
self.free()
423423

424424
def generate_keypair(self):

tests/test_kem.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ def check_wrong_ciphertext(alg_name):
4242
except RuntimeError:
4343
pass
4444
except Exception as ex:
45-
raise AssertionError("An unexpected exception was raised. " + ex)
45+
raise AssertionError(f"An unexpected exception was raised: {ex}")
4646

4747

4848
def test_not_supported():
4949
try:
50-
with oqs.KeyEncapsulation("bogus") as kem:
50+
with oqs.KeyEncapsulation("bogus"):
5151
raise AssertionError("oqs.MechanismNotSupportedError was not raised.")
5252
except oqs.MechanismNotSupportedError:
5353
pass
5454
except Exception as ex:
55-
raise AssertionError("An unexpected exception was raised. " + ex)
55+
raise AssertionError(f"An unexpected exception was raised {ex}")
5656

5757

5858
def test_not_enabled():
@@ -61,21 +61,18 @@ def test_not_enabled():
6161
if alg_name not in oqs.get_enabled_kem_mechanisms():
6262
# Found a non-enabled but supported alg
6363
try:
64-
with oqs.KeyEncapsulation(alg_name) as kem:
64+
with oqs.KeyEncapsulation(alg_name):
6565
raise AssertionError("oqs.MechanismNotEnabledError was not raised.")
6666
except oqs.MechanismNotEnabledError:
6767
pass
6868
except Exception as ex:
69-
raise AssertionError("An unexpected exception was raised. " + ex)
69+
raise AssertionError(f"An unexpected exception was raised: {ex}")
7070

7171

7272
if __name__ == "__main__":
7373
try:
7474
import nose2
7575

7676
nose2.main()
77-
7877
except ImportError:
79-
import nose
80-
81-
nose.runmodule()
78+
raise RuntimeError("nose2 module not found, required to run the unit tests")

tests/test_sig.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ def check_wrong_public_key(alg_name):
9292

9393
def test_not_supported():
9494
try:
95-
with oqs.Signature("bogus") as sig:
95+
with oqs.Signature("bogus"):
9696
raise AssertionError("oqs.MechanismNotSupportedError was not raised.")
9797
except oqs.MechanismNotSupportedError:
9898
pass
9999
except Exception as ex:
100-
raise AssertionError("An unexpected exception was raised. " + ex)
100+
raise AssertionError(f"An unexpected exception was raised: {ex}")
101101

102102

103103
def test_not_enabled():
@@ -106,21 +106,18 @@ def test_not_enabled():
106106
if alg_name not in oqs.get_enabled_sig_mechanisms():
107107
# Found a non-enabled but supported alg
108108
try:
109-
with oqs.Signature(alg_name) as sig:
109+
with oqs.Signature(alg_name):
110110
raise AssertionError("oqs.MechanismNotEnabledError was not raised.")
111111
except oqs.MechanismNotEnabledError:
112112
pass
113113
except Exception as ex:
114-
raise AssertionError("An unexpected exception was raised. " + ex)
114+
raise AssertionError(f"An unexpected exception was raised: {ex}")
115115

116116

117117
if __name__ == "__main__":
118118
try:
119119
import nose2
120120

121121
nose2.main()
122-
123122
except ImportError:
124-
import nose
125-
126-
nose.runmodule()
123+
raise RuntimeError("nose2 module not found, required to run the unit tests")

0 commit comments

Comments
 (0)