From 406cceb7ba53354778ade3b057a126e949ba0e0e Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Mon, 13 Jul 2026 17:53:14 +0000 Subject: [PATCH] Keep end-to-end example test compatible with Python 2.7 subprocess.run() is Python 3.5+. Use Popen with communicate() and a threading.Timer watchdog in place of the communicate() timeout, which is 3.3+. --- tests/test_client_example.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/test_client_example.py b/tests/test_client_example.py index 21c5614..b898b50 100644 --- a/tests/test_client_example.py +++ b/tests/test_client_example.py @@ -26,6 +26,7 @@ import os import socket import subprocess import sys +import threading import wolfssl @@ -150,14 +151,21 @@ def test_default_invocation_end_to_end(): line = server.stdout.readline().decode() assert "Server listening" in line, line - client = subprocess.run( + client = subprocess.Popen( [sys.executable, "-u", os.path.join("examples", "client.py"), "-p", str(port)], - cwd=root, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - timeout=60) + cwd=root, env=env, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + # Watchdog instead of communicate(timeout=...), which is 3.3+. + watchdog = threading.Timer(60, client.kill) + watchdog.start() + try: + out, _ = client.communicate() + finally: + watchdog.cancel() - assert client.returncode == 0, client.stdout.decode() - assert b"I hear you fa shizzle" in client.stdout + assert client.returncode == 0, out.decode() + assert b"I hear you fa shizzle" in out finally: server.kill() server.wait()