From 2b9314af0f33bf2cfb75fab68ec1ad2a4cfdc802 Mon Sep 17 00:00:00 2001 From: Martin Hoyer Date: Thu, 31 Oct 2024 13:55:51 +0100 Subject: [PATCH] Add warning for multiple same checks per test --- tmt/checks/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tmt/checks/__init__.py b/tmt/checks/__init__.py index 0fcafb3e38..145c46b7ab 100644 --- a/tmt/checks/__init__.py +++ b/tmt/checks/__init__.py @@ -1,6 +1,7 @@ import dataclasses import enum import functools +from collections import Counter from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, TypedDict, TypeVar, cast import tmt.log @@ -300,12 +301,20 @@ def normalize_test_checks( # ignore[redundant-cast]: mypy infers the type to be `list[Any]` while # pyright, not making assumptions about the type of items, settles for # `list[Unknown]`. The `cast()` helps pyright, but mypy complains. - return [ + checks = [ normalize_test_check(f'{key_address}[{i}]', raw_test_check, logger) for i, raw_test_check in enumerate( cast(list[Any], raw_checks)) # type: ignore[redundant-cast] ] + how_counts = Counter(check.how for check in checks) + + for how, count in how_counts.items(): + if count > 1: + logger.warning(f"Multiple {how} checks found") + + return checks + raise tmt.utils.NormalizationError( key_address, raw_checks,