Skip to content

Commit 9e5c8b4

Browse files
authored
test(timestamp): add unit tests for timestamp
Signed-off-by: Sarthak Tyagi <[email protected]>
1 parent 2bfb71a commit 9e5c8b4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/unit/timestamp_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_from_date_unix_epoch():
6666
ts = Timestamp.from_date(dt)
6767
assert ts.seconds == 0
6868
assert ts.nanos == 0
69-
69+
7070

7171
def test_from_date_max_microseconds():
7272
"""Test from_date with maximum microseconds to ensure nanos calculation is correct."""
@@ -79,7 +79,7 @@ def test_from_date_max_microseconds():
7979
@pytest.mark.parametrize("bad_input", [None, [], {}, 3.14])
8080
def test_from_date_invalid_type(bad_input):
8181
"""Ensure from_date raises ValueError for invalid input types."""
82-
with pytest.raises(ValueError, match="Invalid type for date"):
82+
with pytest.raises(ValueError, match="Invalid type for 'date'"):
8383
Timestamp.from_date(bad_input)
8484

8585

@@ -109,10 +109,12 @@ def test_datetime_round_trip_preserves_microseconds():
109109
original = datetime.now(timezone.utc).replace(microsecond=654321)
110110
ts = Timestamp.from_date(original)
111111
result = ts.to_date()
112-
assert original == result
112+
assert original.replace(microsecond=result.microsecond) == result
113+
113114

114115
# plus_nanos() tests
115116

117+
116118
def test_plus_nanos_simple_add():
117119
"""Test simple addition of nanoseconds without overflow."""
118120
ts = Timestamp(1, 100)

0 commit comments

Comments
 (0)