Skip to content

Commit 9df0272

Browse files
committed
Tests: fix cached datetime arithmetic contamination between tests using different calendar modes
1 parent 3404f6c commit 9df0272

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

cylc/flow/cycling/iso8601.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def from_nonstandard_string(cls, point_string):
8888

8989
def add(self, other):
9090
"""Add an Interval to self."""
91-
return ISO8601Point(self._iso_point_add(self.value, other.value))
91+
return ISO8601Point(self._iso_point_add(
92+
self.value, other.value, CALENDAR.mode
93+
))
9294

9395
def standardise(self):
9496
"""Reformat self.value into a standard representation."""
@@ -106,41 +108,43 @@ def standardise(self):
106108
def sub(self, other):
107109
"""Subtract a Point or Interval from self."""
108110
if isinstance(other, ISO8601Point):
109-
return ISO8601Interval(
110-
self._iso_point_sub_point(self.value, other.value))
111-
return ISO8601Point(
112-
self._iso_point_sub_interval(self.value, other.value))
111+
return ISO8601Interval(self._iso_point_sub_point(
112+
self.value, other.value, CALENDAR.mode
113+
))
114+
return ISO8601Point(self._iso_point_sub_interval(
115+
self.value, other.value, CALENDAR.mode
116+
))
113117

114118
@staticmethod
115119
@lru_cache(10000)
116-
def _iso_point_add(point_string, interval_string):
120+
def _iso_point_add(point_string, interval_string, _calendar_mode):
117121
"""Add the parsed point_string to the parsed interval_string."""
118122
point = point_parse(point_string)
119123
interval = interval_parse(interval_string)
120124
return str(point + interval)
121125

122126
def _cmp(self, other: 'ISO8601Point') -> int:
123-
return self._iso_point_cmp(self.value, other.value)
127+
return self._iso_point_cmp(self.value, other.value, CALENDAR.mode)
124128

125129
@staticmethod
126130
@lru_cache(10000)
127-
def _iso_point_cmp(point_string, other_point_string):
131+
def _iso_point_cmp(point_string, other_point_string, _calendar_mode):
128132
"""Compare the parsed point_string to the other one."""
129133
point = point_parse(point_string)
130134
other_point = point_parse(other_point_string)
131135
return cmp(point, other_point)
132136

133137
@staticmethod
134138
@lru_cache(10000)
135-
def _iso_point_sub_interval(point_string, interval_string):
139+
def _iso_point_sub_interval(point_string, interval_string, _calendar_mode):
136140
"""Return the parsed point_string minus the parsed interval_string."""
137141
point = point_parse(point_string)
138142
interval = interval_parse(interval_string)
139143
return str(point - interval)
140144

141145
@staticmethod
142146
@lru_cache(10000)
143-
def _iso_point_sub_point(point_string, other_point_string):
147+
def _iso_point_sub_point(point_string, other_point_string, _calendar_mode):
144148
"""Return the difference between the two parsed point strings."""
145149
point = point_parse(point_string)
146150
other_point = point_parse(other_point_string)

0 commit comments

Comments
 (0)