Skip to content

Commit 83a123e

Browse files
committed
fix: Replace Unicode symbols with ASCII for Windows cp1252 compatibility --test --v 0.0.6
1 parent f83325a commit 83a123e

1 file changed

Lines changed: 56 additions & 55 deletions

File tree

libs/python/tests/test_all.py

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def check_c_binaries():
2020
# Try to create a simple hash object
2121
h = Hash(HashAlgorithm.SHA256)
2222
C_BINARIES_AVAILABLE = True
23-
print(" C binaries detected - running full functionality tests")
23+
print(" ℹ C binaries detected - running full functionality tests")
2424
except RuntimeError as e:
2525
if "Could not find NextSSL binaries" in str(e):
2626
C_BINARIES_AVAILABLE = False
27-
print(" C binaries not available - running structure validation only")
27+
print(" ℹ C binaries not available - running structure validation only")
2828
else:
2929
raise
3030
except Exception:
@@ -39,11 +39,11 @@ def test_imports():
3939
try:
4040
import nextssl
4141
from nextssl import hash, dhcm, pow, pqc, primitives, kdf, encoding, root, unsafe
42-
print(" All modules imported successfully")
42+
print(" [PASS] All modules imported successfully")
4343
check_c_binaries() # Check binary availability once
4444
return True
4545
except Exception as e:
46-
print(f" Import failed: {e}")
46+
print(f" [FAIL] Import failed: {e}")
4747
traceback.print_exc()
4848
return False
4949

@@ -82,22 +82,22 @@ def test_hash_algorithms():
8282
argon2d = Argon2(variant='d')
8383
assert argon2d.variant == 'd'
8484

85-
print(f" Tested {len(algorithms)} hash algorithms with full functionality")
85+
print(f" [PASS] Tested {len(algorithms)} hash algorithms with full functionality")
8686
else:
8787
# Structure validation only
8888
for algo in algorithms:
8989
assert isinstance(algo.value, int)
9090
assert callable(Hash) and callable(BLAKE2) and callable(SHAKE) and callable(Argon2)
91-
print(f" Verified {len(algorithms)} hash algorithms (structure only)")
91+
print(f" [PASS] Verified {len(algorithms)} hash algorithms (structure only)")
9292

9393
return True
9494
except RuntimeError as e:
9595
if "Could not find NextSSL binaries" in str(e):
96-
print(f" Skipped: C binaries not available")
96+
print(f" âš  Skipped: C binaries not available")
9797
return True
9898
raise
9999
except Exception as e:
100-
print(f" Hash test failed: {e}")
100+
print(f" [FAIL] Hash test failed: {e}")
101101
traceback.print_exc()
102102
return False
103103

@@ -122,22 +122,22 @@ def test_pqc_kem_algorithms():
122122
assert kem.public_key_size > 0
123123
assert kem.secret_key_size > 0
124124
assert kem.ciphertext_size > 0
125-
print(f" Tested {len(algorithms)} KEM algorithms with full functionality")
125+
print(f" [PASS] Tested {len(algorithms)} KEM algorithms with full functionality")
126126
else:
127127
# Structure validation only
128128
for algo in algorithms:
129129
assert isinstance(algo.value, int)
130130
assert callable(KEM)
131-
print(f" Verified {len(algorithms)} KEM algorithms (structure only)")
131+
print(f" [PASS] Verified {len(algorithms)} KEM algorithms (structure only)")
132132

133133
return True
134134
except RuntimeError as e:
135135
if "Could not find NextSSL binaries" in str(e):
136-
print(f" Skipped: C binaries not available")
136+
print(f" âš  Skipped: C binaries not available")
137137
return True
138138
raise
139139
except Exception as e:
140-
print(f" PQC KEM test failed: {e}")
140+
print(f" [FAIL] PQC KEM test failed: {e}")
141141
traceback.print_exc()
142142
return False
143143

@@ -163,22 +163,22 @@ def test_pqc_sign_algorithms():
163163
assert signer.public_key_size > 0
164164
assert signer.secret_key_size > 0
165165
assert signer.signature_size > 0
166-
print(f" Tested {len(algorithms)} signature algorithms with full functionality")
166+
print(f" [PASS] Tested {len(algorithms)} signature algorithms with full functionality")
167167
else:
168168
# Structure validation only
169169
for algo in algorithms:
170170
assert isinstance(algo.value, int)
171171
assert callable(Sign)
172-
print(f" Verified {len(algorithms)} signature algorithms (structure only)")
172+
print(f" [PASS] Verified {len(algorithms)} signature algorithms (structure only)")
173173

174174
return True
175175
except RuntimeError as e:
176176
if "Could not find NextSSL binaries" in str(e):
177-
print(f" Skipped: C binaries not available")
177+
print(f" âš  Skipped: C binaries not available")
178178
return True
179179
raise
180180
except Exception as e:
181-
print(f" PQC signature test failed: {e}")
181+
print(f" [FAIL] PQC signature test failed: {e}")
182182
traceback.print_exc()
183183
return False
184184

@@ -205,22 +205,22 @@ def test_aes_modes():
205205
# Test ChaCha20-Poly1305
206206
chacha = ChaCha20Poly1305()
207207
assert chacha is not None
208-
print(f" Tested {len(modes)} AES modes + ChaCha20-Poly1305 with full functionality")
208+
print(f" [PASS] Tested {len(modes)} AES modes + ChaCha20-Poly1305 with full functionality")
209209
else:
210210
# Structure validation only
211211
for mode in modes:
212212
assert isinstance(mode.value, int)
213213
assert callable(AES) and callable(ChaCha20Poly1305)
214-
print(f" Verified {len(modes)} AES modes + ChaCha20-Poly1305 (structure only)")
214+
print(f" [PASS] Verified {len(modes)} AES modes + ChaCha20-Poly1305 (structure only)")
215215

216216
return True
217217
except RuntimeError as e:
218218
if "Could not find NextSSL binaries" in str(e):
219-
print(f" Skipped: C binaries not available")
219+
print(f" âš  Skipped: C binaries not available")
220220
return True
221221
raise
222222
except Exception as e:
223-
print(f" AES cipher test failed: {e}")
223+
print(f" [FAIL] AES cipher test failed: {e}")
224224
traceback.print_exc()
225225
return False
226226

@@ -255,22 +255,22 @@ def test_ecc_curves():
255255
assert ristretto.ELEMENT_SIZE == 32
256256

257257
elligator = Elligator2()
258-
print(" Tested 6 ECC curves with full functionality")
258+
print(" [PASS] Tested 6 ECC curves with full functionality")
259259
else:
260260
# Structure validation only
261261
curves = [Ed25519, Ed448, Curve25519, Curve448, Ristretto255, Elligator2]
262262
for curve_class in curves:
263263
assert callable(curve_class)
264-
print(" Verified 6 ECC curves (structure only)")
264+
print(" [PASS] Verified 6 ECC curves (structure only)")
265265

266266
return True
267267
except RuntimeError as e:
268268
if "Could not find NextSSL binaries" in str(e):
269-
print(f" Skipped: C binaries not available")
269+
print(f" âš  Skipped: C binaries not available")
270270
return True
271271
raise
272272
except Exception as e:
273-
print(f" ECC test failed: {e}")
273+
print(f" [FAIL] ECC test failed: {e}")
274274
traceback.print_exc()
275275
return False
276276

@@ -297,22 +297,22 @@ def test_mac_algorithms():
297297
# Test SipHash
298298
siphash = SipHash(c=2, d=4, output_size=8)
299299
assert siphash.output_size == 8
300-
print(f" Tested {len(algorithms)} MAC algorithms + SipHash with full functionality")
300+
print(f" [PASS] Tested {len(algorithms)} MAC algorithms + SipHash with full functionality")
301301
else:
302302
# Structure validation only
303303
for algo in algorithms:
304304
assert isinstance(algo.value, int)
305305
assert callable(MAC) and callable(SipHash)
306-
print(f" Verified {len(algorithms)} MAC algorithms + SipHash (structure only)")
306+
print(f" [PASS] Verified {len(algorithms)} MAC algorithms + SipHash (structure only)")
307307

308308
return True
309309
except RuntimeError as e:
310310
if "Could not find NextSSL binaries" in str(e):
311-
print(f" Skipped: C binaries not available")
311+
print(f" âš  Skipped: C binaries not available")
312312
return True
313313
raise
314314
except Exception as e:
315-
print(f" MAC test failed: {e}")
315+
print(f" [FAIL] MAC test failed: {e}")
316316
traceback.print_exc()
317317
return False
318318

@@ -342,22 +342,22 @@ def test_kdf_functions():
342342
# Test TLS 1.3 HKDF
343343
tls_hkdf = TLS13_HKDF()
344344
assert tls_hkdf is not None
345-
print(" Tested 5 KDF functions with full functionality")
345+
print(" [PASS] Tested 5 KDF functions with full functionality")
346346
else:
347347
# Structure validation only
348348
for algo in algorithms:
349349
assert isinstance(algo.value, int)
350350
assert callable(HKDF) and callable(KDF_SHAKE256) and callable(TLS13_HKDF)
351-
print(" Verified 5 KDF functions (structure only)")
351+
print(" [PASS] Verified 5 KDF functions (structure only)")
352352

353353
return True
354354
except RuntimeError as e:
355355
if "Could not find NextSSL binaries" in str(e):
356-
print(f" Skipped: C binaries not available")
356+
print(f" âš  Skipped: C binaries not available")
357357
return True
358358
raise
359359
except Exception as e:
360-
print(f" KDF test failed: {e}")
360+
print(f" [FAIL] KDF test failed: {e}")
361361
traceback.print_exc()
362362
return False
363363

@@ -393,22 +393,22 @@ def test_encoding():
393393

394394
hex_str = hexencode(test_data)
395395
assert isinstance(hex_str, str)
396-
print(" Tested Base64, Hex, FlexFrame-70 with full functionality")
396+
print(" [PASS] Tested Base64, Hex, FlexFrame-70 with full functionality")
397397
else:
398398
# Structure validation only
399399
assert callable(Base64) and callable(Hex) and callable(FlexFrame70)
400400
assert callable(b64encode) and callable(b64decode)
401401
assert callable(hexencode) and callable(hexdecode)
402-
print(" Verified encoding utilities (structure only)")
402+
print(" [PASS] Verified encoding utilities (structure only)")
403403

404404
return True
405405
except RuntimeError as e:
406406
if "Could not find NextSSL binaries" in str(e):
407-
print(f" Skipped: C binaries not available")
407+
print(f" âš  Skipped: C binaries not available")
408408
return True
409409
raise
410410
except Exception as e:
411-
print(f" Encoding test failed: {e}")
411+
print(f" [FAIL] Encoding test failed: {e}")
412412
traceback.print_exc()
413413
return False
414414

@@ -440,24 +440,24 @@ def test_dhcm():
440440
for diff in difficulties:
441441
# Structure test - actual computation requires more complex setup
442442
pass
443-
print(f" Tested DHCM with {len(algorithms)} algorithms and {len(difficulties)} difficulty models")
443+
print(f" [PASS] Tested DHCM with {len(algorithms)} algorithms and {len(difficulties)} difficulty models")
444444
else:
445445
# Structure validation only
446446
for algo in algorithms:
447447
assert isinstance(algo.value, int)
448448
for diff in difficulties:
449449
assert isinstance(diff.value, int)
450450
assert callable(DHCM)
451-
print(f" Verified DHCM with {len(algorithms)} algorithms and {len(difficulties)} difficulty models (structure only)")
451+
print(f" [PASS] Verified DHCM with {len(algorithms)} algorithms and {len(difficulties)} difficulty models (structure only)")
452452

453453
return True
454454
except RuntimeError as e:
455455
if "Could not find NextSSL binaries" in str(e):
456-
print(f" Skipped: C binaries not available")
456+
print(f" âš  Skipped: C binaries not available")
457457
return True
458458
raise
459459
except Exception as e:
460-
print(f" DHCM test failed: {e}")
460+
print(f" [FAIL] DHCM test failed: {e}")
461461
traceback.print_exc()
462462
return False
463463

@@ -482,22 +482,22 @@ def test_pow():
482482
server = PoWServer(algo)
483483
assert client.algorithm == algo
484484
assert server.algorithm == algo
485-
print(f" Tested PoW with {len(algorithms)} algorithms with full functionality")
485+
print(f" [PASS] Tested PoW with {len(algorithms)} algorithms with full functionality")
486486
else:
487487
# Structure validation only
488488
for algo in algorithms:
489489
assert isinstance(algo.value, int)
490490
assert callable(PoWClient) and callable(PoWServer)
491-
print(f" Verified PoW with {len(algorithms)} algorithms (structure only)")
491+
print(f" [PASS] Verified PoW with {len(algorithms)} algorithms (structure only)")
492492

493493
return True
494494
except RuntimeError as e:
495495
if "Could not find NextSSL binaries" in str(e):
496-
print(f" Skipped: C binaries not available")
496+
print(f" âš  Skipped: C binaries not available")
497497
return True
498498
raise
499499
except Exception as e:
500-
print(f" PoW test failed: {e}")
500+
print(f" [FAIL] PoW test failed: {e}")
501501
traceback.print_exc()
502502
return False
503503

@@ -522,22 +522,22 @@ def test_root_operations():
522522
assert callable(nextssl.root.reseed_drbg)
523523
assert callable(nextssl.root.set_udbf)
524524
assert callable(nextssl.root.clear_udbf)
525-
print(" Tested DRBG and UDBF with full functionality")
525+
print(" [PASS] Tested DRBG and UDBF with full functionality")
526526
else:
527527
# Structure validation only
528528
assert callable(DRBG) and callable(UDBF)
529529
assert callable(nextssl.root.seed_drbg) and callable(nextssl.root.reseed_drbg)
530530
assert callable(nextssl.root.set_udbf) and callable(nextssl.root.clear_udbf)
531-
print(" Verified DRBG and UDBF (structure only)")
531+
print(" [PASS] Verified DRBG and UDBF (structure only)")
532532

533533
return True
534534
except RuntimeError as e:
535535
if "Could not find NextSSL binaries" in str(e):
536-
print(f" Skipped: C binaries not available")
536+
print(f" âš  Skipped: C binaries not available")
537537
return True
538538
raise
539539
except Exception as e:
540-
print(f" Root operations test failed: {e}")
540+
print(f" [FAIL] Root operations test failed: {e}")
541541
traceback.print_exc()
542542
return False
543543

@@ -569,23 +569,23 @@ def test_unsafe_algorithms():
569569
assert callable(nextssl.unsafe.sha0)
570570
assert callable(nextssl.unsafe.md4)
571571
assert callable(nextssl.unsafe.md2)
572-
print(f" Tested {len(algorithms)} unsafe/legacy algorithms with full functionality")
572+
print(f" [PASS] Tested {len(algorithms)} unsafe/legacy algorithms with full functionality")
573573
else:
574574
# Structure validation only
575575
for algo in algorithms:
576576
assert isinstance(algo.value, int)
577577
assert callable(UnsafeHash)
578578
assert callable(nextssl.unsafe.md5) and callable(nextssl.unsafe.sha1)
579-
print(f" Verified {len(algorithms)} unsafe/legacy algorithms (structure only)")
579+
print(f" [PASS] Verified {len(algorithms)} unsafe/legacy algorithms (structure only)")
580580

581581
return True
582582
except RuntimeError as e:
583583
if "Could not find NextSSL binaries" in str(e):
584-
print(f" Skipped: C binaries not available")
584+
print(f" âš  Skipped: C binaries not available")
585585
return True
586586
raise
587587
except Exception as e:
588-
print(f" Unsafe algorithms test failed: {e}")
588+
print(f" [FAIL] Unsafe algorithms test failed: {e}")
589589
traceback.print_exc()
590590
return False
591591

@@ -622,7 +622,7 @@ def main():
622622
else:
623623
failed += 1
624624
except Exception as e:
625-
print(f"\n {name} CRASHED: {e}")
625+
print(f"\n[FAIL] {name} CRASHED: {e}")
626626
traceback.print_exc()
627627
failed += 1
628628

@@ -631,13 +631,14 @@ def main():
631631
print("=" * 70)
632632

633633
if failed > 0:
634-
print("\n⚠️ Some tests failed - this is expected as C API bindings are not yet implemented.")
634+
print("\n⚠️ Some tests failed - this is expected as C API bindings are not yet implemented.")
635635
print(" The tests verify that all classes, enums, and structures are properly defined.")
636636
sys.exit(0) # Don't fail CI - we're testing structure, not functionality yet
637637
else:
638-
print("\n All tests passed!")
638+
print("\n[SUCCESS] All tests passed!")
639639
sys.exit(0)
640640

641641

642642
if __name__ == "__main__":
643643
main()
644+

0 commit comments

Comments
 (0)