test: fix test_schema_validation_containers_storage_conf
The test starts failing because a new version of jsonschema (4.21.0) changed the error messages for `minProperties: 1`. To fix this we just use a regex and check for both possible values. As a drive-by the commit also improves the error output in case the match is not found.
This commit is contained in:
parent
c4ff215149
commit
84059544e4
1 changed files with 6 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -61,8 +62,9 @@ def test_containers_storage_conf_integration(tmp_path, test_filename, test_stora
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"test_data,storage_test_data,expected_err",
|
"test_data,storage_test_data,expected_err",
|
||||||
[
|
[
|
||||||
# None
|
# None, note that starting from jsonschema 4.21.0 the error changes
|
||||||
({}, {}, "does not have enough properties"),
|
# so we need a regexp here
|
||||||
|
({}, {}, r"does not have enough properties|should be non-empty"),
|
||||||
# All options
|
# All options
|
||||||
({
|
({
|
||||||
"filename": "/etc/containers/storage.conf",
|
"filename": "/etc/containers/storage.conf",
|
||||||
|
|
@ -119,4 +121,5 @@ def test_schema_validation_containers_storage_conf(test_data, storage_test_data,
|
||||||
else:
|
else:
|
||||||
assert res.valid is False
|
assert res.valid is False
|
||||||
err_msgs = [e.as_dict()["message"] for e in res.errors]
|
err_msgs = [e.as_dict()["message"] for e in res.errors]
|
||||||
assert expected_err in err_msgs[0] or expected_err in err_msgs[1]
|
assert any(re.search(expected_err, err_msg)
|
||||||
|
for err_msg in err_msgs), f"{expected_err} not found in {err_msgs}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue