Skip to content

Commit

Permalink
Update docs/usages/markers.rst
Browse files Browse the repository at this point in the history
Co-authored-by: Fu Hanxi <[email protected]>
  • Loading branch information
horw and hfudev committed Jan 15, 2025
1 parent f3dddd0 commit 5f6e5f6
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions docs/usages/markers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,44 @@ The ``skip_if_soc`` marker simplifies this by allowing you to define conditions
Examples
========

Common Usage
------------
Here are examples of how to use ``skip_if_soc`` with different conditions:

Here’s an example of how you can use ``skip_if_soc`` with different conditions:

#. **Condition 1**. A boolean expression such as: ``SOC_ULP_SUPPORTED != 1 and SOC_UART_NUM != 3`` This skips tests for chips that:
**Condition 1**: A boolean expression such as ``SOC_ULP_SUPPORTED != 1 and SOC_UART_NUM != 3``. This skips tests for chips that:

- Do not support the ``low power mode`` feature (``SOC_ULP_SUPPORTED != 1``).
- **And** have a UART number that is not equal to 3 (``SOC_UART_NUM != 3``).

#. **Condition 2**. A boolean expression such as: ``SOC_ULP_SUPPORTED != 1 or SOC_UART_NUM != 3`` This skips tests for chips that:

- Either do not support the ``low power mode`` feature (``SOC_ULP_SUPPORTED != 1``).
- **Or** have a UART number that is not equal to 3 (``SOC_UART_NUM != 3``).

Replace ``{condition_xxx}`` and ``{targets}`` with your values.
- **And** have a UART number other than 3 (``SOC_UART_NUM != 3``).

.. code:: python
@pytest.mark.skip_if_soc("{condition_one}")
@pytest.mark.parametrize("target", "{targets}", indirect=True)
@pytest.mark.skip_if_soc("SOC_ULP_SUPPORTED != 1 and SOC_UART_NUM != 3")
@pytest.mark.parametrize("target", ["esp32", "esp32s2", "esp32c3"], indirect=True)
def test_template_first_condition():
pass
----

**Condition 2**: A boolean expression such as ``SOC_ULP_SUPPORTED != 1 or SOC_UART_NUM != 3``. This skips tests for chips that:

@pytest.mark.skip_if_soc("{condition_two}")
@pytest.mark.parametrize("target", "{targets}", indirect=True)
- Either do not support the ``low power mode`` feature (``SOC_ULP_SUPPORTED != 1``).
- **Or** have a UART number other than 3 (``SOC_UART_NUM != 3``).

.. code:: python
@pytest.mark.skip_if_soc("SOC_ULP_SUPPORTED != 1 or SOC_UART_NUM != 3")
@pytest.mark.parametrize("target", ["esp32", "esp32s2", "esp32c3"], indirect=True)
def test_template_second_condition():
pass
Supported Targets
-----------------
----

The ``esp_bool_parser`` library provides the ``SUPPORTED_TARGETS`` constant, which contains a list of all supported chips. You can use this constant to dynamically filter targets based on your conditions.
**Condition 3**: You can use a shortcut to apply this condition to all ESP-IDF supported targets (assuming ``IDF_PATH`` is set).

.. code:: python
import pytest
from esp_bool_parser.constants import SUPPORTED_TARGETS
@pytest.mark.skip_if_soc("{condition}")
@pytest.mark.skip_if_soc("SOC_ULP_SUPPORTED != 1")
@pytest.mark.parametrize("target", SUPPORTED_TARGETS, indirect=True)
def test_template():
pass

0 comments on commit 5f6e5f6

Please sign in to comment.