Skip to content

Commit 3963530

Browse files
formating
1 parent b7ee29f commit 3963530

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/neo4j/time/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,12 @@ def __new__(
20192019
return cls.combine(Date(year, month, day),
20202020
Time(hour, minute, second, nanosecond, tzinfo))
20212021

2022+
# SERIALIZATION #
2023+
2024+
def __reduce__(cls):
2025+
return (cls.__class__,
2026+
(cls.year, cls.month, cls.day, cls.hour, cls.minute, cls.second, cls.nanosecond, cls.tzinfo))
2027+
20222028
# CLASS METHODS #
20232029

20242030
@classmethod

tests/unit/common/time/test_datetime.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import copy
2020
import itertools
2121
import operator
22+
import pickle
2223
from datetime import (
2324
datetime,
2425
timedelta,
@@ -410,6 +411,11 @@ def test_datetime_deep_copy(self) -> None:
410411
assert d is not d2
411412
assert d == d2
412413

414+
def test_datetime_pickle(self) -> None:
415+
expected = DateTime(2023, 12, 7, 12, 34, 56, 7890)
416+
actual = pickle.loads(pickle.dumps(expected))
417+
assert expected == actual
418+
413419

414420
def test_iso_format_with_time_zone_case_1() -> None:
415421
# python -m pytest tests/unit/time/test_datetime.py -s -v -k test_iso_format_with_time_zone_case_1

0 commit comments

Comments
 (0)