File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -734,8 +734,8 @@ def union_simplify(self, other: BaseMarker) -> BaseMarker | None:
734
734
if not shared_markers :
735
735
return None
736
736
737
- unique_markers = our_markers - their_markers
738
- other_unique_markers = their_markers - our_markers
737
+ unique_markers = ( m for m in self . markers if m not in their_markers )
738
+ other_unique_markers = ( m for m in other . markers if m not in our_markers )
739
739
unique_union = MultiMarker (* unique_markers ).union (
740
740
MultiMarker (* other_unique_markers )
741
741
)
@@ -908,8 +908,8 @@ def intersect_simplify(self, other: BaseMarker) -> BaseMarker | None:
908
908
if not shared_markers :
909
909
return None
910
910
911
- unique_markers = our_markers - their_markers
912
- other_unique_markers = their_markers - our_markers
911
+ unique_markers = ( m for m in self . markers if m not in their_markers )
912
+ other_unique_markers = ( m for m in other . markers if m not in our_markers )
913
913
unique_intersection = MarkerUnion (* unique_markers ).intersect (
914
914
MarkerUnion (* other_unique_markers )
915
915
)
Original file line number Diff line number Diff line change @@ -2154,6 +2154,35 @@ def test_complex_intersection() -> None:
2154
2154
)
2155
2155
2156
2156
2157
+ def test_complex_union_is_deterministic () -> None :
2158
+ """
2159
+ This test might fail sporadically if marker operations are not deterministic!
2160
+ """
2161
+ m1 = parse_marker (
2162
+ 'sys_platform != "darwin" and python_version >= "3.12"'
2163
+ ' and platform_system != "Emscripten" and (python_version < "4.0"'
2164
+ ' and sys_platform == "linux" and extra == "stretch"'
2165
+ ' or platform_system == "Windows" or extra == "test"'
2166
+ ' and sys_platform == "win32")'
2167
+ )
2168
+ m2 = parse_marker (
2169
+ 'sys_platform == "linux" and python_version >= "3.12"'
2170
+ ' and platform_system == "Emscripten" and python_version < "4.0"'
2171
+ ' and extra == "stretch" or sys_platform == "win32"'
2172
+ ' and python_version >= "3.12" and platform_system == "Emscripten"'
2173
+ ' and extra == "test"'
2174
+ )
2175
+ assert str (m1 .union (m2 )) == (
2176
+ 'python_version >= "3.12" and platform_system == "Windows"'
2177
+ ' and sys_platform != "darwin" or sys_platform == "linux"'
2178
+ ' and python_version >= "3.12" and python_version < "4.0"'
2179
+ ' and extra == "stretch" or python_version >= "3.12" and python_version < "4.0"'
2180
+ ' and extra == "stretch" and extra == "test" and (sys_platform == "linux"'
2181
+ ' or sys_platform == "win32") or sys_platform == "win32"'
2182
+ ' and python_version >= "3.12" and extra == "test"'
2183
+ )
2184
+
2185
+
2157
2186
def test_union_avoids_combinatorial_explosion () -> None :
2158
2187
"""
2159
2188
combinatorial explosion without AtomicMultiMarker and AtomicMarkerUnion
You can’t perform that action at this time.
0 commit comments