@@ -897,6 +897,96 @@ def test_multi_marker_union_multi_is_multi(
897
897
@pytest .mark .parametrize (
898
898
"marker1, marker2, expected" ,
899
899
[
900
+ # Equivalent ranges
901
+ (
902
+ 'python_version == "3.8" or python_version == "3.9"' ,
903
+ 'python_version >= "3.8" and python_version <= "3.9"' ,
904
+ 'python_version >= "3.8" and python_version < "3.10"' ,
905
+ ),
906
+ (
907
+ 'python_version == "3.8" or python_version == "3.9"' ,
908
+ (
909
+ 'python_version >= "3.8" and python_version <= "3.9"'
910
+ ' and sys_platform == "linux"'
911
+ ),
912
+ 'python_version >= "3.8" and python_version < "3.10"' ,
913
+ ),
914
+ (
915
+ 'python_version == "3.8" or python_version == "3.9"' ,
916
+ (
917
+ 'python_version >= "3.8" and python_version <= "3.9"'
918
+ ' and sys_platform == "linux"'
919
+ ),
920
+ 'python_version >= "3.8" and python_version < "3.10"' ,
921
+ ),
922
+ (
923
+ 'python_version == "3.8" or python_version == "3.9"' ,
924
+ (
925
+ 'python_version >= "3.8" and python_version < "3.10"'
926
+ ' and sys_platform == "linux"'
927
+ ),
928
+ 'python_version >= "3.8" and python_version < "3.10"' ,
929
+ ),
930
+ (
931
+ 'python_version == "3.8" or python_version == "3.9"' ,
932
+ (
933
+ 'python_version > "3.7" and python_version < "3.10"'
934
+ ' and sys_platform == "linux"'
935
+ ),
936
+ 'python_version > "3.7" and python_version < "3.10"' ,
937
+ ),
938
+ (
939
+ 'python_version == "3.8" or python_version == "3.9"' ,
940
+ (
941
+ 'python_version > "3.7" and python_version <= "3.9"'
942
+ ' and sys_platform == "linux"'
943
+ ),
944
+ 'python_version > "3.7" and python_version < "3.10"' ,
945
+ ),
946
+ (
947
+ (
948
+ 'python_version == "3.8" or python_version == "3.9"'
949
+ ' or python_version == "3.10"'
950
+ ),
951
+ (
952
+ 'python_version >= "3.8" and python_version <= "3.10"'
953
+ ' and sys_platform == "linux"'
954
+ ),
955
+ 'python_version >= "3.8" and python_version <= "3.10"' ,
956
+ ),
957
+ (
958
+ (
959
+ 'python_version == "3.8" or python_version == "3.9"'
960
+ ' or python_version == "3.10"'
961
+ ),
962
+ (
963
+ 'python_version >= "3.8" and python_version < "3.11"'
964
+ ' and sys_platform == "linux"'
965
+ ),
966
+ 'python_version >= "3.8" and python_version < "3.11"' ,
967
+ ),
968
+ (
969
+ (
970
+ 'python_version == "3.8" or python_version == "3.9"'
971
+ ' or python_version == "3.10"'
972
+ ),
973
+ (
974
+ 'python_version > "3.7" and python_version <= "3.10"'
975
+ ' and sys_platform == "linux"'
976
+ ),
977
+ 'python_version > "3.7" and python_version <= "3.10"' ,
978
+ ),
979
+ (
980
+ (
981
+ 'python_version == "3.8" or python_version == "3.9"'
982
+ ' or python_version == "3.10"'
983
+ ),
984
+ (
985
+ 'python_version > "3.7" and python_version < "3.11"'
986
+ ' and sys_platform == "linux"'
987
+ ),
988
+ 'python_version > "3.7" and python_version < "3.11"' ,
989
+ ),
900
990
# Ranges with same start
901
991
(
902
992
'python_version >= "3.6" and python_full_version < "3.6.2"' ,
@@ -913,7 +1003,12 @@ def test_multi_marker_union_multi_is_multi(
913
1003
'python_version > "3.6" and python_version < "3.8"' ,
914
1004
'python_version > "3.6" and python_version < "3.8"' ,
915
1005
),
916
- # Ranges meet exactly
1006
+ (
1007
+ 'python_version > "3.7"' ,
1008
+ 'python_version >= "3.8" and sys_platform == "linux"' ,
1009
+ 'python_version > "3.7"' ,
1010
+ ),
1011
+ # Ranges meet exactly (adjacent ranges)
917
1012
(
918
1013
'python_version >= "3.6" and python_full_version < "3.6.2"' ,
919
1014
'python_full_version >= "3.6.2" and python_version < "3.7"' ,
@@ -934,6 +1029,21 @@ def test_multi_marker_union_multi_is_multi(
934
1029
'python_full_version > "3.6.2" and python_version < "3.8"' ,
935
1030
'python_version >= "3.6" and python_version < "3.8"' ,
936
1031
),
1032
+ (
1033
+ 'python_version >= "3.8" and python_version < "3.9"' ,
1034
+ 'python_version >= "3.9" and python_version < "3.11"' ,
1035
+ 'python_version >= "3.8" and python_version < "3.11"' ,
1036
+ ),
1037
+ (
1038
+ 'python_version >= "3.8" and python_version < "3.9"' ,
1039
+ 'python_version >= "3.9" and python_version < "3.10"' ,
1040
+ 'python_version >= "3.8" and python_version < "3.10"' ,
1041
+ ),
1042
+ (
1043
+ 'python_version == "3.8"' ,
1044
+ 'python_version == "3.9"' ,
1045
+ 'python_version >= "3.8" and python_version < "3.10"' ,
1046
+ ),
937
1047
# Ranges overlap
938
1048
(
939
1049
'python_version >= "3.6" and python_full_version <= "3.6.8"' ,
@@ -992,6 +1102,19 @@ def test_multi_marker_union_multi_is_multi(
992
1102
'python_version == "3.7" and implementation_name == "cpython"' ,
993
1103
'python_version >= "3.6" and python_version <= "3.7"' ,
994
1104
),
1105
+ # complex
1106
+ (
1107
+ 'python_version == "3.10" and platform_system == "Linux"' ,
1108
+ (
1109
+ 'python_version == "3.11" and platform_system != "Darwin"'
1110
+ ' or platform_system != "Linux" and platform_system != "Darwin"'
1111
+ ' and python_version <= "3.11" and python_full_version >= "3.10.0"'
1112
+ ),
1113
+ (
1114
+ 'python_version >= "3.10" and python_version <= "3.11"'
1115
+ ' and platform_system != "Darwin"'
1116
+ ),
1117
+ ),
995
1118
],
996
1119
)
997
1120
def test_version_ranges_collapse_on_union (
@@ -2177,8 +2300,8 @@ def test_complex_union() -> None:
2177
2300
]
2178
2301
assert (
2179
2302
str (union (* markers ))
2180
- == 'python_version >= "3.6 " and platform_system == "Darwin "'
2181
- ' and platform_machine == "arm64 " or python_version >= "3.10"'
2303
+ == 'platform_system == "Darwin " and platform_machine == "arm64 "'
2304
+ ' and python_version >= "3.6 " or python_version >= "3.10"'
2182
2305
)
2183
2306
2184
2307
@@ -2210,8 +2333,8 @@ def test_complex_intersection() -> None:
2210
2333
]
2211
2334
assert (
2212
2335
str (dnf (intersection (* markers ).invert ()))
2213
- == 'python_version >= "3.6 " and platform_system == "Darwin "'
2214
- ' and platform_machine == "arm64 " or python_version >= "3.10"'
2336
+ == 'platform_system == "Darwin " and platform_machine == "arm64 "'
2337
+ ' and python_version >= "3.6 " or python_version >= "3.10"'
2215
2338
)
2216
2339
2217
2340
0 commit comments