You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2026/08/31 13:02:42 UTC
(iceberg-python) branch main updated: test(datetime): cover invalid timestamp errors in nanos conversions (#3651)
This is an automated email from the ASF dual-hosted git repository.
Fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git
The following commit(s) were added to refs/heads/main by this push:
new 7a6c2ecc9 test(datetime): cover invalid timestamp errors in nanos conversions (#3651)
7a6c2ecc9 is described below
commit 7a6c2ecc9141b13c572753c1dac1a3bba1aadbfe
Author: vishnu prakash <nv...@gmail.com>
AuthorDate: Mon Aug 31 18:32:35 2026 +0530
test(datetime): cover invalid timestamp errors in nanos conversions (#3651)
* test(datetime): cover invalid timestamp errors in nanos conversions
* test(datetime): assert full error messages
---
tests/utils/test_datetime.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tests/utils/test_datetime.py b/tests/utils/test_datetime.py
index d7a6f431e..54fd3eefc 100644
--- a/tests/utils/test_datetime.py
+++ b/tests/utils/test_datetime.py
@@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+import re
from datetime import datetime, time, timezone, tzinfo
import pytest
@@ -125,6 +126,11 @@ def test_timestamp_to_nanos_unexpected_zone_offset() -> None:
timestamp_to_nanos("2025-02-23T16:21:44.375612001-04:00")
+def test_timestamp_to_nanos_invalid_timestamp() -> None:
+ with pytest.raises(ValueError, match=re.escape("Invalid timestamp without zone: invalid (must be ISO-8601)")):
+ timestamp_to_nanos("invalid")
+
+
@pytest.mark.parametrize(
"timestamp, nanos",
[
@@ -144,6 +150,11 @@ def test_timestamptz_to_nanos_missing_zone_offset() -> None:
timestamptz_to_nanos("2025-02-23T20:21:44.375612001")
+def test_timestamptz_to_nanos_invalid_timestamp() -> None:
+ with pytest.raises(ValueError, match=re.escape("Invalid timestamp with zone: invalid (must be ISO-8601)")):
+ timestamptz_to_nanos("invalid")
+
+
@pytest.mark.parametrize("nanos, micros", [(1510871468000001001, 1510871468000001), (-1510871468000001001, -1510871468000002)])
def test_nanos_to_micros(nanos: int, micros: int) -> None:
assert micros == nanos_to_micros(nanos)