|
16 | 16 | CURRENT_PY_ENV = f"py{sys.version_info[0]}{sys.version_info[1]}" # e.g. py310
|
17 | 17 |
|
18 | 18 |
|
| 19 | +@pytest.mark.parametrize( |
| 20 | + ("user_input", "env_names", "is_all", "is_default" ), [ |
| 21 | + (None, (), False, True ), |
| 22 | + ("", (), False, True ), |
| 23 | + ("a1", ("a1",), False, False ), |
| 24 | + ("a1,b2,c3", ("a1", "b2", "c3"), False, False ), |
| 25 | + # If the user gives "ALL" as any envname, this becomes an "is_all" and other envnames are ignored. |
| 26 | + ("ALL", (), True, False ), |
| 27 | + ("a1,ALL,b2", (), True, False ), |
| 28 | + # Zero-length envnames are ignored as being not present. This is not intentional. |
| 29 | + (",,a1,,,b2,,", ("a1", "b2"), False, False ), |
| 30 | + (",,", (), False, True ), |
| 31 | + # Environment names with "invalid" characters are accepted here; the client is expected to deal with this. |
| 32 | + ("\x01.-@\x02,xxx", ("\x01.-@\x02", "xxx"), False, False ), |
| 33 | + ], |
| 34 | +) |
| 35 | +def test_clienv(user_input: str, env_names: tuple[str], is_all: bool, is_default: bool) -> None: |
| 36 | + ce = CliEnv(user_input) |
| 37 | + assert (ce.is_all, ce.is_default_list, tuple(ce)) \ |
| 38 | + == (is_all, is_default, tuple(env_names)) |
| 39 | + |
| 40 | +@pytest.mark.parametrize( |
| 41 | + ("user_input", "expected"), |
| 42 | + [ |
| 43 | + ("", False), |
| 44 | + ("all", False), |
| 45 | + ("All", False), |
| 46 | + ("ALL", True), |
| 47 | + ("a,ALL,b", True), |
| 48 | + ], |
| 49 | +) |
| 50 | +def test_clienv_is_all(user_input: str, expected: bool) -> None: |
| 51 | + assert CliEnv(user_input).is_all is expected |
| 52 | + |
| 53 | + |
19 | 54 | def test_env_select_lazily_looks_at_envs() -> None:
|
20 | 55 | state = State(get_options(), [])
|
21 | 56 | env_selector = EnvSelector(state)
|
|
0 commit comments