From 4fd9d9d05149a1b757246db163beed4b5140cde3 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Fri, 16 Feb 2024 19:34:35 +0200 Subject: [PATCH 1/3] gh-115567: Catch test output --- Lib/test/test_ctypes/test_callbacks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_ctypes/test_callbacks.py b/Lib/test/test_ctypes/test_callbacks.py index 19f4158c0ac846..8e01cdc5af4a48 100644 --- a/Lib/test/test_ctypes/test_callbacks.py +++ b/Lib/test/test_ctypes/test_callbacks.py @@ -149,8 +149,9 @@ def callback(a, b): return c dll = cdll[_ctypes_test.__file__] # With no fix for i38748, the next line will raise OSError and cause the test to fail. - self.assertEqual(dll._test_i38748_runCallback(callback, 5, 10), 15) - + with support.captured_stdout() as out: + self.assertEqual(dll._test_i38748_runCallback(callback, 5, 10), 15) + self.assertEqual(out.getvalue(), "a=5, b=10, c=15\n") if hasattr(ctypes, 'WINFUNCTYPE'): class StdcallCallbacks(Callbacks): From 00a320cf1936f42d00fd9bf95b9c88789fed8720 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Fri, 16 Feb 2024 21:29:32 +0200 Subject: [PATCH 2/3] Move with statement one line above --- Lib/test/test_ctypes/test_callbacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_ctypes/test_callbacks.py b/Lib/test/test_ctypes/test_callbacks.py index 8e01cdc5af4a48..41c10907c91591 100644 --- a/Lib/test/test_ctypes/test_callbacks.py +++ b/Lib/test/test_ctypes/test_callbacks.py @@ -148,8 +148,8 @@ def callback(a, b): print(f"a={a}, b={b}, c={c}") return c dll = cdll[_ctypes_test.__file__] - # With no fix for i38748, the next line will raise OSError and cause the test to fail. with support.captured_stdout() as out: + # With no fix for i38748, the next line will raise OSError and cause the test to fail. self.assertEqual(dll._test_i38748_runCallback(callback, 5, 10), 15) self.assertEqual(out.getvalue(), "a=5, b=10, c=15\n") From 1302994c953e27cea480ac284fee40fa8ce10fcf Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Fri, 16 Feb 2024 22:53:53 +0300 Subject: [PATCH 3/3] Update Lib/test/test_ctypes/test_callbacks.py Co-authored-by: Serhiy Storchaka --- Lib/test/test_ctypes/test_callbacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_ctypes/test_callbacks.py b/Lib/test/test_ctypes/test_callbacks.py index 41c10907c91591..64f92ffdca6a3f 100644 --- a/Lib/test/test_ctypes/test_callbacks.py +++ b/Lib/test/test_ctypes/test_callbacks.py @@ -149,7 +149,7 @@ def callback(a, b): return c dll = cdll[_ctypes_test.__file__] with support.captured_stdout() as out: - # With no fix for i38748, the next line will raise OSError and cause the test to fail. + # With no fix for i38748, the next line will raise OSError and cause the test to fail. self.assertEqual(dll._test_i38748_runCallback(callback, 5, 10), 15) self.assertEqual(out.getvalue(), "a=5, b=10, c=15\n")