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 1
1
from __future__ import annotations
2
2
3
+ import copy
3
4
import operator
4
5
5
6
from datetime import date
@@ -453,3 +454,10 @@ def __eq__(self, other: object) -> bool:
453
454
454
455
def __ne__ (self , other : object ) -> bool :
455
456
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 1
1
from __future__ import annotations
2
2
3
3
import pickle
4
+ import copy
4
5
5
6
from datetime import timedelta
6
7
@@ -65,3 +66,18 @@ def test_inequality():
65
66
66
67
assert interval1 != interval2
67
68
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