pytest-embedded-idf 2.9.2__tar.gz → 2.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-embedded-idf
3
+ Version: 2.10.0
4
+ Summary: Make pytest-embedded plugin work with ESP-IDF.
5
+ Author-email: Fu Hanxi <fuhanxi@espressif.com>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Framework :: Pytest
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Topic :: Software Development :: Testing
22
+ License-File: LICENSE
23
+ Requires-Dist: pytest-embedded~=2.10.0
24
+ Requires-Dist: esp-idf-panic-decoder
25
+ Requires-Dist: esp-bool-parser>=0.1.2,<1
26
+ Requires-Dist: pytest-embedded-serial-esp~=2.10.0 ; extra == "serial"
27
+ Requires-Dist: esp-coredump~=1.0 ; extra == "serial"
28
+ Project-URL: changelog, https://github.com/espressif/pytest-embedded/blob/main/CHANGELOG.md
29
+ Project-URL: documentation, https://docs.espressif.com/projects/pytest-embedded/en/latest/
30
+ Project-URL: homepage, https://github.com/espressif/pytest-embedded
31
+ Project-URL: repository, https://github.com/espressif/pytest-embedded
32
+ Provides-Extra: serial
33
+
34
+ ### pytest-embedded-idf
35
+
36
+ A `pytest-embedded` service tailored for [ESP-IDF](https://github.com/espressif/esp-idf) applications and test workflows.
37
+
38
+ #### Service Activation
39
+
40
+ Activate this service by passing `idf` to `--embedded-services`. Typically used together with `esp` for physical hardware testing:
41
+
42
+ ```shell
43
+ pytest --embedded-services esp,idf --app-path /path/to/esp-idf-app
44
+ ```
45
+
46
+ #### Extra Functionalities
47
+
48
+ - **App Metadata Parsing**: Reads `project_description.json` and build artifacts to identify the target chip, flash settings, partition tables, and binary paths.
49
+ - **Smart Flashing & Caching**: Automatically flashes the bootloader, partition table, and application. Caches binary hashes across the session to skip redundant flashing.
50
+ - **Panic & Core Dump Decoding**: Automatically parses and decodes panic stack traces and core dumps from target flash/UART when a test fails.
51
+ - **Partition Table & NVS Controls**: Erase NVS blocks or customize the partition tool script.
52
+ - **Unity Test Runner**: Integrated support for Unity C test suites via `dut.expect_unity_test_output()` and the `case_tester` fixture for test menu navigation.
53
+ - **Linux Target Support**: Includes `LinuxDut` and `LinuxSerial` to test ESP-IDF POSIX/Linux applications directly on the host machine.
54
+ - **Dynamic Parametrization**: Provides `idf_parametrize` to expand `supported_targets` and filter chips by SoC capability strings.
55
+
56
+ #### CLI Options
57
+
58
+ - `--supported-targets`: Comma-separated list of officially supported targets for the test. Default: `None`.
59
+ - `--preview-targets`: Comma-separated list of preview/experimental targets for the test. Default: `None`.
60
+ - `--part-tool`: Path to the partition table generator script. Default: `$IDF_PATH/components/partition_table/gen_esp32part.py`.
61
+ - `--confirm-target-elf-sha256`: Verify ELF SHA256 against target flash before skipping re-flashing. Default: `False`.
62
+ - `--erase-nvs`: Erase NVS partition blocks when flashing binaries. Default: `False`.
63
+ - `--skip-check-coredump`: Skip auto-checking for core dumps and panic traces on test failure. Default: `False`.
64
+
65
+ #### Quick Example
66
+
67
+ ```python
68
+ from pytest_embedded import Dut
69
+
70
+
71
+ def test_idf_app(dut: Dut):
72
+ # App information is parsed automatically from the ESP-IDF build directory
73
+ print(f'Running target: {dut.app.target}')
74
+ dut.expect('Booting ESP-IDF app...')
75
+ dut.expect('Hello world!')
76
+ ```
77
+
@@ -0,0 +1,43 @@
1
+ ### pytest-embedded-idf
2
+
3
+ A `pytest-embedded` service tailored for [ESP-IDF](https://github.com/espressif/esp-idf) applications and test workflows.
4
+
5
+ #### Service Activation
6
+
7
+ Activate this service by passing `idf` to `--embedded-services`. Typically used together with `esp` for physical hardware testing:
8
+
9
+ ```shell
10
+ pytest --embedded-services esp,idf --app-path /path/to/esp-idf-app
11
+ ```
12
+
13
+ #### Extra Functionalities
14
+
15
+ - **App Metadata Parsing**: Reads `project_description.json` and build artifacts to identify the target chip, flash settings, partition tables, and binary paths.
16
+ - **Smart Flashing & Caching**: Automatically flashes the bootloader, partition table, and application. Caches binary hashes across the session to skip redundant flashing.
17
+ - **Panic & Core Dump Decoding**: Automatically parses and decodes panic stack traces and core dumps from target flash/UART when a test fails.
18
+ - **Partition Table & NVS Controls**: Erase NVS blocks or customize the partition tool script.
19
+ - **Unity Test Runner**: Integrated support for Unity C test suites via `dut.expect_unity_test_output()` and the `case_tester` fixture for test menu navigation.
20
+ - **Linux Target Support**: Includes `LinuxDut` and `LinuxSerial` to test ESP-IDF POSIX/Linux applications directly on the host machine.
21
+ - **Dynamic Parametrization**: Provides `idf_parametrize` to expand `supported_targets` and filter chips by SoC capability strings.
22
+
23
+ #### CLI Options
24
+
25
+ - `--supported-targets`: Comma-separated list of officially supported targets for the test. Default: `None`.
26
+ - `--preview-targets`: Comma-separated list of preview/experimental targets for the test. Default: `None`.
27
+ - `--part-tool`: Path to the partition table generator script. Default: `$IDF_PATH/components/partition_table/gen_esp32part.py`.
28
+ - `--confirm-target-elf-sha256`: Verify ELF SHA256 against target flash before skipping re-flashing. Default: `False`.
29
+ - `--erase-nvs`: Erase NVS partition blocks when flashing binaries. Default: `False`.
30
+ - `--skip-check-coredump`: Skip auto-checking for core dumps and panic traces on test failure. Default: `False`.
31
+
32
+ #### Quick Example
33
+
34
+ ```python
35
+ from pytest_embedded import Dut
36
+
37
+
38
+ def test_idf_app(dut: Dut):
39
+ # App information is parsed automatically from the ESP-IDF build directory
40
+ print(f'Running target: {dut.app.target}')
41
+ dut.expect('Booting ESP-IDF app...')
42
+ dut.expect('Hello world!')
43
+ ```
@@ -29,14 +29,14 @@ dynamic = ["version", "description"]
29
29
  requires-python = ">=3.10"
30
30
 
31
31
  dependencies = [
32
- "pytest-embedded~=2.9.2",
32
+ "pytest-embedded~=2.10.0",
33
33
  "esp-idf-panic-decoder",
34
34
  "esp-bool-parser>=0.1.2,<1"
35
35
  ]
36
36
 
37
37
  [project.optional-dependencies]
38
38
  serial = [
39
- "pytest-embedded-serial-esp~=2.9.2",
39
+ "pytest-embedded-serial-esp~=2.10.0",
40
40
  "esp-coredump~=1.0",
41
41
  ]
42
42
 
@@ -33,4 +33,4 @@ __all__ = [
33
33
  'UnittestMenuCase',
34
34
  ]
35
35
 
36
- __version__ = '2.9.2'
36
+ __version__ = '2.10.0'
@@ -116,7 +116,8 @@ class IdfApp(App):
116
116
  logging.warning(f"{sdkconfig_json_path} doesn't exist. Skipping...")
117
117
  self._sdkconfig = {}
118
118
  else:
119
- self._sdkconfig = json.load(open(sdkconfig_json_path))
119
+ with open(sdkconfig_json_path, encoding='utf-8') as f:
120
+ self._sdkconfig = json.load(f)
120
121
  return self._sdkconfig
121
122
 
122
123
  @property
@@ -178,7 +179,8 @@ class IdfApp(App):
178
179
 
179
180
  partition_table = {}
180
181
  for line in raw_data.splitlines():
181
- if line[0] != '#':
182
+ line = line.strip()
183
+ if line and not line.startswith('#'):
182
184
  try:
183
185
  _name, _type, _subtype, _offset, _size, _flags = line.split(',')
184
186
  if _size[-1] == 'K':
@@ -830,16 +830,14 @@ class MultiDevRunTestManager:
830
830
 
831
831
  class CaseTester:
832
832
  """
833
- The Generic tester of all the types
833
+ Generic runner and manager for Unity test cases on target DUTs.
834
834
 
835
- Attributes:
836
- dut (IdfDut): The first dut if there is more than one
837
- test_menu (t.List[UnittestMenuCase]): The list of the cases
835
+ Supports running single-device and multi-device test cases parsed from the Unity test menu.
838
836
  """
839
837
 
840
838
  def __init__(self, dut: t.Union['IdfDut', list['IdfDut']]) -> None: # type: ignore
841
839
  """
842
- Create the object for every dut and put them into the group
840
+ Initialize the CaseTester with one or more target DUTs.
843
841
  """
844
842
  if isinstance(dut, Iterable):
845
843
  self.is_multi_dut = True
@@ -55,21 +55,21 @@ def idf_parametrize(
55
55
  indirect: (bool | t.Sequence[str]) = False,
56
56
  ) -> t.Callable[..., None]:
57
57
  """
58
- A decorator to unify pytest.mark.parametrize usage in esp-idf.
58
+ A decorator to unify pytest.mark.parametrize usage for ESP-IDF tests.
59
59
 
60
60
  Args:
61
- param_names: A comma-separated string of parameter names that will be passed to
62
- the test function.
63
- values: A list of parameter values where each value corresponds to the parameters
64
- defined in param_names.
65
- indirect: A list of arguments names (subset of argnames) or a boolean. If True
66
- the list contains all names from the argnames. Each argvalue corresponding to an
67
- argname in this list will be passed as request.param to its respective argname
68
- fixture function so that it can perform more expensive setups during the setup
69
- phase of a test rather than at collection time.
61
+ param_names: Comma-separated parameter names passed to the test function.
62
+ Supports special parameters:
63
+ - 'target': Automatically expands the placeholder strings 'supported_targets'
64
+ and 'preview_targets' into lists of target chips.
65
+ - 'markers': If provided, accepts test marks (e.g. pytest.mark.usb_device)
66
+ as the last element of each parameter tuple without passing them as function arguments.
67
+ values: List of parameter values corresponding to param_names.
68
+ indirect: Sequence of argument names or boolean indicating whether parameters
69
+ are passed indirectly to fixture functions.
70
70
 
71
71
  Returns:
72
- Decorated test function with parametrization applied
72
+ Decorated test function with parametrization applied.
73
73
  """
74
74
  param_list = [name.strip() for name in param_names.split(',')]
75
75
  for param in param_list:
@@ -1,52 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pytest-embedded-idf
3
- Version: 2.9.2
4
- Summary: Make pytest-embedded plugin work with ESP-IDF.
5
- Author-email: Fu Hanxi <fuhanxi@espressif.com>
6
- Requires-Python: >=3.10
7
- Description-Content-Type: text/markdown
8
- Classifier: Development Status :: 5 - Production/Stable
9
- Classifier: Framework :: Pytest
10
- Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python :: 3 :: Only
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Programming Language :: Python :: 3.14
20
- Classifier: Programming Language :: Python
21
- Classifier: Topic :: Software Development :: Testing
22
- License-File: LICENSE
23
- Requires-Dist: pytest-embedded~=2.9.2
24
- Requires-Dist: esp-idf-panic-decoder
25
- Requires-Dist: esp-bool-parser>=0.1.2,<1
26
- Requires-Dist: pytest-embedded-serial-esp~=2.9.2 ; extra == "serial"
27
- Requires-Dist: esp-coredump~=1.0 ; extra == "serial"
28
- Project-URL: changelog, https://github.com/espressif/pytest-embedded/blob/main/CHANGELOG.md
29
- Project-URL: documentation, https://docs.espressif.com/projects/pytest-embedded/en/latest/
30
- Project-URL: homepage, https://github.com/espressif/pytest-embedded
31
- Project-URL: repository, https://github.com/espressif/pytest-embedded
32
- Provides-Extra: serial
33
-
34
- ### pytest-embedded-idf
35
-
36
- pytest embedded service for esp-idf project
37
-
38
- Extra Functionalities:
39
-
40
- ```{eval-rst}
41
- .. tabs::
42
-
43
- .. group-tab:: `pytest-embedded-serial-esp` activated
44
-
45
- - `app`: parse the built binary by idf rules and gather more information.
46
- - `serial`: auto flash the built binary into the target board at the beginning when running test cases.
47
-
48
- .. group-tab:: `pytest-embedded-serial-esp` NOT activated
49
-
50
- - `app`: parse the built binary by idf rules and gather more information.
51
- ```
52
-
@@ -1,18 +0,0 @@
1
- ### pytest-embedded-idf
2
-
3
- pytest embedded service for esp-idf project
4
-
5
- Extra Functionalities:
6
-
7
- ```{eval-rst}
8
- .. tabs::
9
-
10
- .. group-tab:: `pytest-embedded-serial-esp` activated
11
-
12
- - `app`: parse the built binary by idf rules and gather more information.
13
- - `serial`: auto flash the built binary into the target board at the beginning when running test cases.
14
-
15
- .. group-tab:: `pytest-embedded-serial-esp` NOT activated
16
-
17
- - `app`: parse the built binary by idf rules and gather more information.
18
- ```