From 52367a92b1fac59f32b3b8d403f3528b470bddac Mon Sep 17 00:00:00 2001 From: KennyMcSimpson <70093673+KennyMcSimpson@users.noreply.github.com> Date: Sat, 24 Oct 2026 21:45:19 +0800 Subject: [PATCH] Test closed descriptors without localized error messages --- tests/test_strict_soft.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_strict_soft.py b/tests/test_strict_soft.py index f1ce879b..23dde186 100644 --- a/tests/test_strict_soft.py +++ b/tests/test_strict_soft.py @@ -379,10 +379,9 @@ def fail_sentinel_inspection(fd: int) -> os.stat_result: with pytest.raises(OSError, match="sentinel inspection failed"): lock.acquire() assert inspected_fd is not None - # A closed descriptor reports EBADF on every platform, but the message differs (Windows says "handle is invalid"). - with pytest.raises(OSError, match=r"Bad file descriptor|handle is invalid") as closed: + # The error message depends on the OS language; the closed-descriptor errno is stable. + with pytest.raises(OSError, check=lambda error: error.errno == EBADF): real_fstat(inspected_fd) - assert closed.value.errno == EBADF assert (lock.is_locked, lock.lock_counter, lock.claims) == (False, 0, ())