tests/net_inet/tls_num_errors.py: Switch to tls mod and require mbedTLS.

This test is very specific to mbedTLS and how it raises errors when the
heap is locked.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-10-07 12:52:14 +11:00
parent a3867590f9
commit e1a6c11f42

View File

@@ -1,6 +1,11 @@
# test that modtls produces a numerical error message when out of heap
import socket, ssl, sys
import socket, tls
# This test is specific to the mbedTLS implementation, so require that.
if not hasattr(tls, "MBEDTLS_VERSION"):
print("SKIP")
raise SystemExit
try:
from micropython import heap_lock, heap_unlock
@@ -18,11 +23,13 @@ except:
# test with heap locked to see it switch to number-only error message
def test(addr):
ctx = tls.SSLContext(tls.PROTOCOL_TLS_CLIENT)
ctx.verify_mode = tls.CERT_NONE
s = socket.socket()
s.connect(addr)
try:
s.setblocking(False)
s = ssl.wrap_socket(s, do_handshake=False)
s = ctx.wrap_socket(s, do_handshake_on_connect=False)
heap_lock()
print("heap is locked")
while True: