@@ -2368,6 +2368,44 @@ def test_complex_intersection() -> None:
2368
2368
)
2369
2369
2370
2370
2371
+ def test_complex_intersection_with_itertools_product_duplicates () -> None :
2372
+ """
2373
+ Real-world example from https://github.com/python-poetry/poetry/issues/10250.
2374
+ (Only occurs if the solver takes an unfortunate path.)
2375
+ Takes a long time without filtering duplicates from the itertools.product()
2376
+ in cnf/dnf early.
2377
+ """
2378
+ m1 = parse_marker (
2379
+ '(python_version > "3.9" or platform_system != "Windows"'
2380
+ ' or platform_machine != "x86") and (python_version != "3.10"'
2381
+ ' or platform_system != "Windows" or platform_python_implementation == "PyPy")'
2382
+ )
2383
+ m2 = parse_marker (
2384
+ '(platform_system != "Windows" or platform_machine != "x86"'
2385
+ ' or python_version >= "3.10" and python_version < "3.12")'
2386
+ ' and (sys_platform != "darwin" or platform_machine != "arm64")'
2387
+ ' and python_version <= "3.11" and (platform_system != "Windows"'
2388
+ ' or platform_python_implementation == "PyPy" or python_version == "3.9"'
2389
+ ' or python_version == "3.11") and python_version >= "3.9"'
2390
+ ' and (platform_system != "Windows" or platform_python_implementation == "PyPy"'
2391
+ ' or platform_machine != "x86" or python_version == "3.11")'
2392
+ )
2393
+
2394
+ assert str (m1 .intersect (m2 )) == (
2395
+ '(python_version > "3.9" or platform_system != "Windows"'
2396
+ ' or platform_machine != "x86") and (python_version != "3.10"'
2397
+ ' or platform_system != "Windows" or platform_python_implementation == "PyPy")'
2398
+ ' and (platform_system != "Windows" or platform_machine != "x86"'
2399
+ ' or python_version >= "3.10") and python_version <= "3.11"'
2400
+ ' and (sys_platform != "darwin" or platform_machine != "arm64") and'
2401
+ ' (platform_system != "Windows" or platform_python_implementation == "PyPy"'
2402
+ ' or python_version == "3.9" or python_version == "3.11")'
2403
+ ' and python_version >= "3.9" and (platform_system != "Windows"'
2404
+ ' or platform_python_implementation == "PyPy" or platform_machine != "x86"'
2405
+ ' or python_version == "3.11")'
2406
+ )
2407
+
2408
+
2371
2409
def test_complex_union_is_deterministic () -> None :
2372
2410
"""
2373
2411
This test might fail sporadically if marker operations are not deterministic!
0 commit comments