|
19 | 19 | from itertools import product |
20 | 20 | import os |
21 | 21 | from pathlib import Path |
| 22 | +import re |
22 | 23 | from shlex import split |
23 | 24 | from subprocess import run |
24 | 25 | from types import SimpleNamespace |
25 | 26 |
|
26 | 27 | import pytest |
27 | | -from pytest import param |
28 | 28 |
|
| 29 | +from cylc.flow.exceptions import InputError |
29 | 30 | from cylc.rose.entry_points import pre_configure |
30 | 31 | from cylc.rose.utilities import NotARoseSuiteException, load_rose_config |
31 | 32 |
|
32 | 33 |
|
33 | | -@pytest.mark.parametrize( |
34 | | - 'srcdir, expect', |
35 | | - [ |
36 | | - param( |
37 | | - '07_cli_override', |
38 | | - 'failed 1.1\n(add --verbose for more context)', |
39 | | - id='template variable not set' |
40 | | - ) |
41 | | - ] |
42 | | -) |
43 | | -async def test_validate_fail(srcdir, expect, cylc_validate_cli): |
44 | | - srcdir = Path(__file__).parent / srcdir |
45 | | - validate = await cylc_validate_cli(srcdir) |
46 | | - assert validate.ret == 1 |
47 | | - if expect: |
48 | | - assert expect == str(validate.exc) |
| 34 | +async def test_validate_fail_tvar_not_set(cylc_validate_cli): |
| 35 | + with pytest.raises( |
| 36 | + InputError, |
| 37 | + match=re.escape('failed 1.1\n(add --verbose for more context)') |
| 38 | + ): |
| 39 | + await cylc_validate_cli(Path(__file__).parent / '07_cli_override') |
49 | 40 |
|
50 | 41 |
|
51 | 42 | @pytest.mark.parametrize( |
@@ -75,8 +66,8 @@ async def test_validate(monkeypatch, srcdir, envvars, args, cylc_validate_cli): |
75 | 66 | for key, value in (envvars or {}).items(): |
76 | 67 | monkeypatch.setenv(key, value) |
77 | 68 | srcdir = Path(__file__).parent / srcdir |
78 | | - validate = await cylc_validate_cli(str(srcdir), args) |
79 | | - assert validate.ret == 0 |
| 69 | + # this is the test, we just asserting that this doesn't fail: |
| 70 | + await cylc_validate_cli(str(srcdir), args) |
80 | 71 |
|
81 | 72 |
|
82 | 73 | @pytest.mark.parametrize( |
@@ -241,11 +232,14 @@ async def test_validate_against_source( |
241 | 232 | await cylc_inspect_scripts(wid, {"against_source": True}) |
242 | 233 |
|
243 | 234 | # Reinstall fails if we clear rose install opts: |
244 | | - clear_install_validate = await cylc_validate_cli( |
245 | | - wid, {"against_source": True, 'clear_rose_install_opts': True} |
246 | | - ) |
247 | | - assert clear_install_validate.ret != 0 |
248 | | - assert 'Test --rose-template-variable' in str(clear_install_validate.exc) |
| 235 | + with pytest.raises(InputError, match='Test --rose-template-variable'): |
| 236 | + await cylc_validate_cli( |
| 237 | + wid, |
| 238 | + { |
| 239 | + "against_source": True, |
| 240 | + 'clear_rose_install_opts': True |
| 241 | + } |
| 242 | + ) |
249 | 243 |
|
250 | 244 |
|
251 | 245 | def test_invalid_cli_opts(tmp_path, caplog): |
|
0 commit comments