tests: allow tests to skip version tests if file_names_mapping is empty (#5562)
fix(tests): update ComponentTestBase to skip tests when file_names_mapping is empty - Modified the test method to skip the test instead of raising an AssertionError when no file names mapping is provided. - Improved user feedback by providing a clear message indicating the reason for skipping the test.
This commit is contained in:
parent
af4fb3774e
commit
95314e3fca
1 changed files with 4 additions and 5 deletions
|
|
@ -53,11 +53,8 @@ class ComponentTestBase:
|
||||||
def test_all_versions_have_a_file_name_defined(self, file_names_mapping: list[VersionComponentMapping]) -> None:
|
def test_all_versions_have_a_file_name_defined(self, file_names_mapping: list[VersionComponentMapping]) -> None:
|
||||||
"""Ensure all supported versions have a file name defined."""
|
"""Ensure all supported versions have a file name defined."""
|
||||||
if not file_names_mapping:
|
if not file_names_mapping:
|
||||||
msg = (
|
msg = f"file_names_mapping is empty for {self.__class__.__name__}. Skipping versions test."
|
||||||
f"file_names_mapping is empty for {self.__class__.__name__}. "
|
pytest.skip(msg)
|
||||||
"Please define the version mappings for your component."
|
|
||||||
)
|
|
||||||
raise AssertionError(msg)
|
|
||||||
|
|
||||||
version_mappings = {mapping["version"]: mapping for mapping in file_names_mapping}
|
version_mappings = {mapping["version"]: mapping for mapping in file_names_mapping}
|
||||||
|
|
||||||
|
|
@ -94,6 +91,8 @@ class ComponentTestBase:
|
||||||
file_names_mapping: list[VersionComponentMapping],
|
file_names_mapping: list[VersionComponentMapping],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test if the component works across different versions."""
|
"""Test if the component works across different versions."""
|
||||||
|
if not file_names_mapping:
|
||||||
|
pytest.skip("No file names mapping defined for this component.")
|
||||||
version_mappings = {mapping["version"]: mapping for mapping in file_names_mapping}
|
version_mappings = {mapping["version"]: mapping for mapping in file_names_mapping}
|
||||||
|
|
||||||
mapping = version_mappings[version]
|
mapping = version_mappings[version]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue