Skip to content

fix: init dynamic generated markers when "add target as marker" #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pytest-embedded/pytest_embedded/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ def get_param(item: Function, key: str, default: t.Any = None) -> t.Any:
def pytest_collection_modifyitems(self, config: Config, items: t.List[Function]):
# ------ add marker based on target ------
if self.add_target_as_marker_with_amount or self.add_target_as_marker:
_new_markers: t.Set[str] = set()
for item in items:
item_target = self.get_param(item, 'target')
if not item_target:
Expand All @@ -1293,6 +1294,11 @@ def pytest_collection_modifyitems(self, config: Config, items: t.List[Function])
_marker = targets_to_marker(to_list(parse_multi_dut_args(count, item_target)))
if self.add_target_as_marker:
_marker = '-'.join(to_list(parse_multi_dut_args(count, item_target)))
logging.debug(f'Adding marker {item_target} to {item.name}')
if _marker not in _new_markers:
_new_markers.add(_marker)
logging.debug(f'Registering marker: {_marker}')
config.addinivalue_line('markers', _marker)

item.add_marker(_marker)

Expand Down
Loading