From 78079374ac2b9cb8ae74975c2009fd21d59c130a Mon Sep 17 00:00:00 2001
From: Chad Smith <chad.smith@canonical.com>
Date: Wed, 19 Jan 2022 18:32:08 -0700
Subject: 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
---
 tests/unittests/config/test_schema.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'tests/unittests')

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()
-- 
cgit v1.2.3