From e1a6c11f4238cc31e6f11133d9e8c237919baee0 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 7 Oct 2025 12:52:14 +1100 Subject: [PATCH] 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 --- tests/net_inet/tls_num_errors.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/net_inet/tls_num_errors.py b/tests/net_inet/tls_num_errors.py index 9c12114eab..79678e0727 100644 --- a/tests/net_inet/tls_num_errors.py +++ b/tests/net_inet/tls_num_errors.py @@ -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: