From 7777603e8bb711a723379d04ef23070f55c22feb Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 3 Sep 2021 18:06:34 +0200 Subject: [PATCH] qa: tox.ini: verify yaml syntax Signed-off-by: Sebastian Wagner --- qa/tasks/tests/conftest.py | 12 ++++++++++++ qa/tasks/tests/test_import_yaml.py | 5 +++++ qa/tox.ini | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 qa/tasks/tests/conftest.py create mode 100644 qa/tasks/tests/test_import_yaml.py diff --git a/qa/tasks/tests/conftest.py b/qa/tasks/tests/conftest.py new file mode 100644 index 0000000000000..7cc617a41321f --- /dev/null +++ b/qa/tasks/tests/conftest.py @@ -0,0 +1,12 @@ +import glob + + +def pytest_addoption(parser): + parser.addoption("--suite-dir", help="suite dir") + +def pytest_generate_tests(metafunc): + if "yaml_file" in metafunc.fixturenames: + suite_dir = metafunc.config.getoption("--suite-dir") + files = glob.glob(f"{suite_dir}/**/*.yaml", recursive=True) + + metafunc.parametrize("yaml_file", list(set(files))) diff --git a/qa/tasks/tests/test_import_yaml.py b/qa/tasks/tests/test_import_yaml.py new file mode 100644 index 0000000000000..d6e0e2640c2dc --- /dev/null +++ b/qa/tasks/tests/test_import_yaml.py @@ -0,0 +1,5 @@ +import yaml + + +def test_load_yaml(yaml_file): + yaml.safe_load(open(yaml_file)) diff --git a/qa/tox.ini b/qa/tox.ini index 6d5ae7ecba6b1..7fc94eb5a455b 100644 --- a/qa/tox.ini +++ b/qa/tox.ini @@ -29,7 +29,7 @@ deps = httplib2 commands = pytest --assert=plain test_import.py - pytest tasks/tests + pytest tasks/tests --suite-dir {toxinidir}/suites {posargs} [testenv:deadsymlinks] basepython = python3 -- 2.39.5