Skip to content

Commit 402ae54

Browse files
TheRealFalconholmanb
authored andcommitted
test: fix pytest.raises error text warnings
Dont pass "" as match text. Given that a common paradigm throughout the tests is: text = expected text None = no exception "" = exception with any text Workaround pytest's expectations here.
1 parent e171b68 commit 402ae54

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

tests/unittests/config/test_cc_package_update_upgrade_install.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,7 @@ class TestPackageUpdateUpgradeSchema:
326326
)
327327
@skipUnlessJsonSchema()
328328
def test_schema_validation(self, config, error_msg):
329-
with pytest.raises(SchemaValidationError, match=error_msg):
329+
with pytest.raises(
330+
SchemaValidationError, match=error_msg if error_msg else None
331+
):
330332
validate_cloudconfig_schema(config, get_schema(), strict=True)

tests/unittests/config/test_cc_power_state_change.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,7 @@ def test_schema_validation(self, config, error_msg):
219219
if error_msg is None:
220220
validate_cloudconfig_schema(config, get_schema(), strict=True)
221221
else:
222-
with pytest.raises(SchemaValidationError, match=error_msg):
222+
with pytest.raises(
223+
SchemaValidationError, match=error_msg if error_msg else None
224+
):
223225
validate_cloudconfig_schema(config, get_schema(), strict=True)

tests/unittests/config/test_cc_rsyslog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ def test_schema_validation(self, config, error_msg):
270270
if error_msg is None:
271271
validate_cloudconfig_schema(config, get_schema(), strict=True)
272272
else:
273-
with pytest.raises(SchemaValidationError, match=error_msg):
273+
with pytest.raises(
274+
SchemaValidationError, match=error_msg if error_msg else None
275+
):
274276
validate_cloudconfig_schema(config, get_schema(), strict=True)
275277

276278

tests/unittests/config/test_cc_snap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ def test_schema_validation(self, config, error_msg):
288288
if error_msg is None:
289289
validate_cloudconfig_schema(config, get_schema(), strict=True)
290290
else:
291-
with pytest.raises(SchemaValidationError, match=error_msg):
291+
with pytest.raises(
292+
SchemaValidationError, match=error_msg if error_msg else None
293+
):
292294
validate_cloudconfig_schema(config, get_schema(), strict=True)
293295

294296

0 commit comments

Comments
 (0)