From e8c6e02cb21b064d29b8f9e1ed13afdd0eef4fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Fri, 20 Sep 2024 15:32:11 +0200 Subject: [PATCH] Fix missing `f-string` in the `tmt lint` check Instead of the key name `key "{bad_property}" not recognized` was printed to the user when an invalid key was present in the step phase configuration. --- tests/lint/plan/data/invalid-plugin-key.fmf | 5 +++++ tests/lint/plan/test.sh | 4 ++++ tmt/base.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/lint/plan/data/invalid-plugin-key.fmf diff --git a/tests/lint/plan/data/invalid-plugin-key.fmf b/tests/lint/plan/data/invalid-plugin-key.fmf new file mode 100644 index 0000000000..cca6ed72b7 --- /dev/null +++ b/tests/lint/plan/data/invalid-plugin-key.fmf @@ -0,0 +1,5 @@ +prepare: + how: feature + wrong: key +execute: + how: tmt diff --git a/tests/lint/plan/test.sh b/tests/lint/plan/test.sh index bb20a85aa0..8956b8506a 100755 --- a/tests/lint/plan/test.sh +++ b/tests/lint/plan/test.sh @@ -67,6 +67,10 @@ rlJournalStart rlAssertGrep "fail P001 unknown key \"discove\" is used" $rlRun_LOG rlAssertGrep "fail P001 unknown key \"environmen\" is used" $rlRun_LOG rlAssertGrep "fail P001 unknown key \"summaryABCDEF\" is used" $rlRun_LOG + + rlRun -s "$tmt plan lint invalid-plugin-key" 1 + rlAssertGrep 'warn C000 key "wrong" not recognized by schema$' $rlRun_LOG + rlAssertGrep 'warn C000 key "wrong" not recognized by schema /schemas/prepare/feature' $rlRun_LOG rlPhaseEnd rlPhaseStartTest "P007: step phases require existing guests and roles" diff --git a/tmt/base.py b/tmt/base.py index 13c5ee3841..7aa07407c1 100644 --- a/tmt/base.py +++ b/tmt/base.py @@ -939,7 +939,7 @@ def detect_unallowed_properties(error: jsonschema.ValidationError) -> LinterRetu f'key "{bad_property}" not recognized by schema {error.schema["$id"]}' else: yield LinterOutcome.WARN, \ - 'key "{bad_property}" not recognized by schema' + f'key "{bad_property}" not recognized by schema' # A key not recognized, but when patternProperties are allowed. In that case, # the key is both not listed and not matching the pattern.