-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give better error if unexpected Yaml format
Signed-off-by: Erik Jaegervall <[email protected]>
- Loading branch information
Showing
3 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tests/vspec/test_faulty_vspec_format/test_faulty_vspec_format.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2022 Contributors to COVESA | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Mozilla Public License 2.0 which is available at | ||
# https://www.mozilla.org/en-US/MPL/2.0/ | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
import subprocess | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
HERE = Path(__file__).resolve().parent | ||
TEST_UNITS = HERE / ".." / "test_units.yaml" | ||
TEST_QUANT = HERE / ".." / "test_quantities.yaml" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"filename, error", | ||
[ | ||
("test_single_level.vspec", "Invalid key value: A=None"), | ||
("test_string_as_child.vspec", "Invalid key value: A=string"), | ||
], | ||
) | ||
def test_error(tmp_path, filename, error): | ||
spec = HERE / filename | ||
output = tmp_path / "out.json" | ||
cmd = f"vspec export json -u {TEST_UNITS} -q {TEST_QUANT} --vspec {spec} --output {output}" | ||
process = subprocess.run(cmd.split(), capture_output=True, text=True) | ||
assert process.returncode != 0 | ||
assert error in process.stdout |