9
9
Version ,
10
10
)
11
11
from conda_forge_tick .migrators .recipe_v1 import (
12
+ get_condition ,
12
13
is_negated_condition ,
13
- is_single_expression ,
14
14
)
15
15
16
16
YAML_PATH = Path (__file__ ).parent / "test_v1_yaml"
21
21
)
22
22
23
23
24
- @pytest .mark .parametrize (
25
- "x" ,
26
- [
27
- "win" ,
28
- "not unix" ,
29
- 'cuda_compiler_version == "None"' ,
30
- "build_platform != target_platform" ,
31
- ],
32
- )
33
- def test_is_single_expression (x ):
34
- assert is_single_expression (x )
35
-
36
-
37
- @pytest .mark .parametrize (
38
- "x" ,
39
- [
40
- 'cuda_compiler_version != "None" and linux"' ,
41
- 'unix and blas_impl != "mkl"' ,
42
- "linux or osx" ,
43
- "foo if bar else baz" ,
44
- ],
45
- )
46
- def test_not_is_single_expression (x ):
47
- assert not is_single_expression (x )
48
-
49
-
50
24
@pytest .mark .parametrize (
51
25
"a,b" ,
52
26
[
53
27
("unix" , "not unix" ),
54
28
('cuda_compiler_version == "None"' , 'not cuda_compiler_version == "None"' ),
55
29
('cuda_compiler_version == "None"' , 'cuda_compiler_version != "None"' ),
56
30
('not cuda_compiler_version == "None"' , 'not cuda_compiler_version != "None"' ),
31
+ (
32
+ 'cuda_compiler_version != "None" and linux' ,
33
+ 'not (cuda_compiler_version != "None" and linux)' ,
34
+ ),
35
+ ("linux or osx" , "not (linux or osx)" ),
36
+ ("a >= 14" , "a < 14" ),
37
+ ("a >= 14" , "not (a >= 14)" ),
38
+ ("a in [1, 2, 3]" , "a not in [1, 2, 3]" ),
39
+ ("a in [1, 2, 3]" , "not a in [1, 2, 3]" ),
40
+ ("a + b < 10" , "a + b >= 10" ),
41
+ ("a == b == c" , "not (a == b == c)" ),
57
42
],
58
43
)
59
44
def test_is_negated_condition (a , b ):
60
- assert is_negated_condition (a , b )
61
- assert is_negated_condition (b , a )
45
+ a_cond = get_condition ({"if" : a })
46
+ b_cond = get_condition ({"if" : b })
47
+ assert is_negated_condition (a_cond , b_cond )
48
+ assert is_negated_condition (b_cond , a_cond )
62
49
63
50
64
51
@pytest .mark .parametrize (
@@ -69,11 +56,16 @@ def test_is_negated_condition(a, b):
69
56
('cuda_compiler_version != "None"' , 'not cuda_compiler_version == "None"' ),
70
57
("a or b" , "not a or b" ),
71
58
("a and b" , "not a and b" ),
59
+ ("a == b == c" , "a != b != c" ),
60
+ ("a > 4" , "a < 4" ),
61
+ ("a == b == c" , "not (a == b) == c" ),
72
62
],
73
63
)
74
64
def test_not_is_negated_condition (a , b ):
75
- assert not is_negated_condition (a , b )
76
- assert not is_negated_condition (b , a )
65
+ a_cond = get_condition ({"if" : a })
66
+ b_cond = get_condition ({"if" : b })
67
+ assert not is_negated_condition (a_cond , b_cond )
68
+ assert not is_negated_condition (b_cond , a_cond )
77
69
78
70
79
71
@flaky
0 commit comments