Skip to content

Commit

Permalink
fix: weird bug in show_tag
Browse files Browse the repository at this point in the history
It seems like that BasicTest somehow collides with some new changes on python 3.11+
This lead to failing unittests. Changing the element we import resolved the issue
  • Loading branch information
sebastianpfischer committed May 25, 2024
1 parent 2652e44 commit ce774fc
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 26 deletions.
68 changes: 67 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ sphinx-rtd-theme = "*"
sphinxcontrib-programoutput = "*"
sphinx-autodoc-typehints = "*"
ruff = "0.2.1"
tox = "^4.15.0"

[tool.poetry.scripts]
pykiso = 'pykiso.cli:main'
Expand Down Expand Up @@ -158,3 +159,18 @@ build-backend = "poetry.core.masonry.api"
# Linelength according to PEP 8.
line-length = 120
exclude = ['examples', 'tests', 'tasks.py']

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = True
env_list =
python3.11
python3.12
[testenv]
description = run the tests with pytest
extras = all
allowlist_externals = pytest, poetry, invoke
commands = pytest
"""
15 changes: 7 additions & 8 deletions src/pykiso/tool/show_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

from pykiso.config_parser import parse_config
from pykiso.exceptions import TestCollectionError
from pykiso.test_coordinator import test_execution
from pykiso.test_coordinator.test_case import BasicTest
from pykiso.test_coordinator import test_case, test_execution
from pykiso.types import PathType


Expand Down Expand Up @@ -65,7 +64,7 @@ def get_yaml_files(config_path: PathType, recursive: bool) -> List[Path]:
return config_files


def get_test_cases(cfg_dict: Dict[str, List[dict]]) -> List[BasicTest]:
def get_test_cases(cfg_dict: Dict[str, List[dict]]) -> List[test_case.BasicTest]:
"""Return the list of tests meant to be run by the provided
test configuration file.
Expand All @@ -82,18 +81,18 @@ def get_test_cases(cfg_dict: Dict[str, List[dict]]) -> List[BasicTest]:
return test_cases


def get_test_tags(test_case_list: List[BasicTest]) -> Dict[str, List[str]]:
def get_test_tags(test_case_list: List[test_case.BasicTest]) -> Dict[str, List[str]]:
"""Return the list of tag and values contained in the test case list
:param test_case_list: list of loaded test cases.
:return: dictionary linking the tag names to their values.
"""
tag_dict = {}
# search the tag for each test case
for test_case in test_case_list:
if test_case.tag is None:
for testCase in test_case_list:
if testCase.tag is None:
continue
for tag_name, tag_values in test_case.tag.items():
for tag_name, tag_values in testCase.tag.items():
if tag_name not in tag_dict:
tag_dict[tag_name] = list()
# tag values are lists of strings
Expand All @@ -106,7 +105,7 @@ def get_test_tags(test_case_list: List[BasicTest]) -> Dict[str, List[str]]:

def build_result_dict(
config_file_name: str,
test_case_list: List[BasicTest],
test_case_list: List[test_case.BasicTest],
test_tags: Dict[str, list],
show_test_cases: bool = False,
) -> Dict[str, Union[str, int]]:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_show_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def tmp_yaml_files(tmp_path: Path, request):

@pytest.fixture
def basic_test_mock(mocker):
return mocker.patch("pykiso.tool.show_tag.BasicTest")
return mocker.patch("pykiso.tool.show_tag.test_case.BasicTest")


@pytest.fixture(autouse=True, scope="module")
Expand Down
16 changes: 0 additions & 16 deletions tox.ini

This file was deleted.

0 comments on commit ce774fc

Please sign in to comment.