From 5a369e7a7e60c98b28b1f5db379d8b243d0a8762 Mon Sep 17 00:00:00 2001 From: An Long Date: Thu, 25 Jun 2026 01:26:34 +0900 Subject: [PATCH] Re-raise unexpected exceptions instead of swallowing them in various tests (GH-152019) (cherry picked from commit 6c3da17d1f333f6bd4c07d11e2e304159d550822) Co-authored-by: An Long Co-authored-by: Stan Ulbrych --- Lib/test/test_fcntl.py | 1 + Lib/test/test_launcher.py | 1 + Lib/test/test_pathlib/test_pathlib.py | 1 + Lib/test/test_socket.py | 2 ++ 4 files changed, 5 insertions(+) diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 0570257c5230d51..fe2a4b8ad12a501 100644 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -151,6 +151,7 @@ def test_fcntl_64_bit(self): except OSError as exc: if exc.errno == errno.EINVAL: self.skipTest("F_NOTIFY not available by this environment") + raise fcntl.fcntl(fd, cmd, flags) finally: os.close(fd) diff --git a/Lib/test/test_launcher.py b/Lib/test/test_launcher.py index b2ca8cf2140a108..46466ecf2cd99ec 100644 --- a/Lib/test/test_launcher.py +++ b/Lib/test/test_launcher.py @@ -469,6 +469,7 @@ def test_search_major_2(self): except subprocess.CalledProcessError: if not is_installed("2.7"): raise unittest.SkipTest("requires at least one Python 2.x install") + raise self.assertEqual("PythonCore", data["env.company"]) self.assertTrue(data["env.tag"].startswith("2."), data["env.tag"]) diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index aa2498f7e085431..be8e4dc09aaaeec 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -1109,6 +1109,7 @@ def test_is_socket_true(self): if (isinstance(e, PermissionError) or "AF_UNIX path too long" in str(e)): self.skipTest("cannot bind Unix socket: " + str(e)) + raise self.assertTrue(P.is_socket()) self.assertFalse(P.is_fifo()) self.assertFalse(P.is_file()) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 342e1e037322360..66e02023cac96df 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1409,6 +1409,7 @@ def testIPv6toString(self): except OSError as e: if e.winerror == 10022: self.skipTest('IPv6 might not be supported') + raise f = lambda a: inet_pton(AF_INET6, a) assertInvalid = lambda a: self.assertRaises( @@ -1499,6 +1500,7 @@ def testStringToIPv6(self): except OSError as e: if e.winerror == 10022: self.skipTest('IPv6 might not be supported') + raise f = lambda a: inet_ntop(AF_INET6, a) assertInvalid = lambda a: self.assertRaises(