Skip to content
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

feat: parametrize_wrapper #331

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

horw
Copy link
Member

@horw horw commented Jan 13, 2025

Description

Add idf_parametrize decorator to simplify pytest parametrization by handling target expansion and runner marks via string representation.

  • Automatically expanding special target values ('supported_targets' and 'preview_targets') into individual test cases;
  • Simplifying pytest mark usage by allowing string-based mark definitions instead of direct pytest.mark usage;
  • Unifying the parametrization pattern across esp-idf test cases;

Related

Testing


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@horw horw requested a review from hfudev January 13, 2025 08:05
@horw
Copy link
Member Author

horw commented Jan 13, 2025

Let's add test cases for _expand_target_values, _process_pytest_value, and idf_parametrize itself. @hfudev, if you think some other cases should be covered, let me know, and I will add them.

Copy link
Member

@hfudev hfudev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, please also update our user guide with some examples!

pytest-embedded-idf/pytest_embedded_idf/unity.py Outdated Show resolved Hide resolved
@horw horw force-pushed the feat/parametrize_wrapper branch 2 times, most recently from b827e86 to baf9e4b Compare January 16, 2025 07:53
@horw horw force-pushed the feat/parametrize_wrapper branch from baf9e4b to 2fe15cb Compare January 16, 2025 14:05
Comment on lines +149 to +157
@idf_parametrize('env_marker', [
('generic'),
('sdcard', 'usb_device'),
'sdcard',
'sdcard, generic'
], indirect=True)
@idf_parametrize('target', [
'esp32'
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try support real markers. like

Suggested change
@idf_parametrize('env_marker', [
('generic'),
('sdcard', 'usb_device'),
'sdcard',
'sdcard, generic'
], indirect=True)
@idf_parametrize('target', [
'esp32'
])
@idf_parametrize('env_marker', [
(pytest.mark.skip),
(pytest.mark.foo, pytest.mark.bar),
], indirect=True)
@idf_parametrize('target', [
'esp32'
])

not sure if it's feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants