From 191e33976cd0a1d99a255f23c7397305126754d1 Mon Sep 17 00:00:00 2001 From: Andrian Balanescu Date: Wed, 15 Jul 2026 23:57:01 +0000 Subject: [PATCH] fix: handle platform-specific error messages in overflow timestamp test The test_from_timestamp_with_overflow_value test was failing on Windows because datetime.fromtimestamp raises OSError on Windows (caught by from_timestamp and re-raised as 'Error converting value to datetime'), while the test regex only matched 'out of range' and 'year must be in 1..9999' (the messages from uncaught ValueError on Linux). Updated the regex to also match 'Timestamp is too large' (from caught OverflowError) and 'Error converting value to datetime' (from caught OSError on Windows). Fixes #2999 --- tests/test_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 26c12f6a7..46d074c1e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -124,7 +124,15 @@ def test_from_timestamp_with_negative_value(): def test_from_timestamp_with_overflow_value(): value = 9223372036854775 - with pytest.raises(ValueError, match=r"out of range|year must be in 1\.\.9999"): + # The error message varies by platform: + # - Linux: ValueError("year must be in 1..9999") (not caught by from_timestamp) + # - Some platforms: ValueError("... out of range") (not caught by from_timestamp) + # - Some platforms: OverflowError -> ValueError("Timestamp is too large") + # - Windows: OSError -> ValueError("Error converting value to datetime") + with pytest.raises( + ValueError, + match=r"out of range|year must be in 1\.\.9999|Timestamp is too large|Error converting value to datetime", + ): utils.from_timestamp(value)