From d550ee8ac485262eb5cbd9ce0149cae4c0a5500a Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Wed, 19 Jan 2022 15:55:44 -0700 Subject: [PATCH] tests: focal caplog has whitespace indentation for multi-line logs 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 --- tests/unittests/config/test_schema.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unittests/config/test_schema.py b/tests/unittests/config/test_schema.py index 5cb00c5d419..1647f6e58e6 100644 --- a/tests/unittests/config/test_schema.py +++ b/tests/unittests/config/test_schema.py @@ -234,9 +234,12 @@ def test_validateconfig_schema_non_strict_emits_warnings(self, caplog): """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()