|
1 | 1 | from pathlib import Path
|
2 | 2 |
|
3 | 3 | from flaky import flaky
|
| 4 | +import pytest |
4 | 5 | from test_migrators import run_test_migration
|
5 | 6 |
|
6 | 7 | from conda_forge_tick.migrators import (
|
7 | 8 | CombineV1ConditionsMigrator,
|
8 | 9 | Version,
|
9 | 10 | )
|
| 11 | +from conda_forge_tick.migrators.recipe_v1 import ( |
| 12 | + is_single_expression, |
| 13 | + is_negated_condition, |
| 14 | +) |
10 | 15 |
|
11 | 16 | YAML_PATH = Path(__file__).parent / "test_v1_yaml"
|
12 | 17 |
|
|
16 | 21 | )
|
17 | 22 |
|
18 | 23 |
|
| 24 | +@pytest.mark.parametrize("x", [ |
| 25 | + "win", |
| 26 | + "not unix", |
| 27 | + 'cuda_compiler_version == "None"', |
| 28 | + "build_platform != target_platform", |
| 29 | +]) |
| 30 | +def test_is_single_expression(x): |
| 31 | + assert is_single_expression(x) |
| 32 | + |
| 33 | + |
| 34 | +@pytest.mark.parametrize("x", [ |
| 35 | + 'cuda_compiler_version != "None" and linux"', |
| 36 | + 'unix and blas_impl != "mkl"', |
| 37 | + "linux or osx", |
| 38 | + "foo if bar else baz", |
| 39 | +]) |
| 40 | +def test_not_is_single_expression(x): |
| 41 | + assert not is_single_expression(x) |
| 42 | + |
| 43 | + |
| 44 | +@pytest.mark.parametrize("a,b", [ |
| 45 | + ("unix", "not unix"), |
| 46 | + ('cuda_compiler_version == "None"', 'not cuda_compiler_version == "None"'), |
| 47 | + ('cuda_compiler_version == "None"', 'cuda_compiler_version != "None"'), |
| 48 | + ('not cuda_compiler_version == "None"', 'not cuda_compiler_version != "None"'), |
| 49 | +]) |
| 50 | +def test_is_negated_condition(a, b): |
| 51 | + assert is_negated_condition(a, b) |
| 52 | + assert is_negated_condition(b, a) |
| 53 | + |
| 54 | + |
| 55 | +@pytest.mark.parametrize("a,b", [ |
| 56 | + ("not unix", "not unix"), |
| 57 | + ('cuda_compiler_version == "None"', 'not cuda_compiler_version != "None"'), |
| 58 | + ('cuda_compiler_version != "None"', 'not cuda_compiler_version == "None"'), |
| 59 | + ("a or b", "not a or b"), |
| 60 | + ("a and b", "not a and b"), |
| 61 | +]) |
| 62 | +def test_not_is_negated_condition(a, b): |
| 63 | + assert not is_negated_condition(a, b) |
| 64 | + assert not is_negated_condition(b, a) |
| 65 | + |
| 66 | + |
19 | 67 | @flaky
|
20 | 68 | def test_combine_v1_conditions(tmp_path):
|
21 | 69 | run_test_migration(
|
|
0 commit comments