File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import copy
34import operator
45
56from datetime import date
@@ -453,3 +454,10 @@ def __eq__(self, other: object) -> bool:
453454
454455 def __ne__ (self , other : object ) -> bool :
455456 return not self .__eq__ (other )
457+
458+ def __deepcopy__ (self , memodict : dict [int , Self ]) -> Self :
459+ return self .__class__ (
460+ copy .deepcopy (self .start ),
461+ copy .deepcopy (self .end ),
462+ self ._absolute ,
463+ )
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import pickle
4+ import copy
45
56from datetime import timedelta
67
@@ -65,3 +66,18 @@ def test_inequality():
6566
6667 assert interval1 != interval2
6768 assert interval1 != interval3
69+
70+
71+ def test_deepcopy ():
72+ dt1 = pendulum .datetime (2016 , 11 , 18 )
73+ dt2 = pendulum .datetime (2016 , 11 , 20 )
74+
75+ interval = dt2 - dt1
76+
77+ interval2 = copy .deepcopy (interval )
78+
79+ assert interval == interval2
80+ # make sure it's a deep copy
81+ assert interval is not interval2
82+ assert interval .start is not interval2 .start
83+ assert interval .end is not interval2 .end
You can’t perform that action at this time.
0 commit comments