summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2022-01-19 18:32:08 -0700
committerGitHub <noreply@github.com>2022-01-19 19:32:08 -0600
commit78079374ac2b9cb8ae74975c2009fd21d59c130a (patch)
tree03238a32a559a3e9bd99cf5ccba0a7866c6745b7
parent69f9a7888ea770f4dc0454be91dea225bdd5957c (diff)
downloadvyos-cloud-init-78079374ac2b9cb8ae74975c2009fd21d59c130a.tar.gz
vyos-cloud-init-78079374ac2b9cb8ae74975c2009fd21d59c130a.zip
tests: focal caplog has whitespace indentation for multi-line logs (#1201)
Avoid series-specific log formatting in tests by using caplog.record_tuples. Added benefit, we can easily check log-level WARNING too. Fixes unit tests from Focal Package builds at: https://code.launchpad.net/~cloud-init-dev/+archive/ubuntu/daily/\ +build/23076508
-rw-r--r--tests/unittests/config/test_schema.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/unittests/config/test_schema.py b/tests/unittests/config/test_schema.py
index 5cb00c5d..1647f6e5 100644
--- a/tests/unittests/config/test_schema.py
+++ b/tests/unittests/config/test_schema.py
@@ -234,9 +234,12 @@ class TestValidateCloudConfigSchema:
"""When strict is False validate_cloudconfig_schema emits warnings."""
schema = {"properties": {"p1": {"type": "string"}}}
validate_cloudconfig_schema({"p1": -1}, schema, strict=False)
+ [(module, log_level, log_msg)] = caplog.record_tuples
+ assert "cloudinit.config.schema" == module
+ assert logging.WARNING == log_level
assert (
- "Invalid cloud-config provided:\np1: -1 is not of type 'string'\n"
- in (caplog.text)
+ "Invalid cloud-config provided:\np1: -1 is not of type 'string'"
+ == log_msg
)
@skipUnlessJsonSchema()