Skip to content

Commit 86f52f1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent be247ef commit 86f52f1

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

docs/usages/expecting.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ As with the :func:`~pytest_embedded.dut.Dut.expect` function, the ``pattern`` ar
186186
for _ in range(2):
187187
dut.expect_exact(pattern_list)
188188
189-
*****************************
189+
***************************
190190
Multi-DUT Synchronization
191-
*****************************
191+
***************************
192192

193193
When you use ``--count N`` (or equivalent), each board has its own serial stream and its own :class:`~pytest_embedded.dut.Dut` instance. Waiting for readiness on each device with separate ``expect`` calls works, but:
194194

195-
- Sequential calls use **per-call** timeouts, so two ``expect_exact(..., timeout=120)`` lines can behave like a much larger wall-clock budget than a single 120s deadline.
196-
- The **slowest** device should not delay matching on others more than your chosen global timeout.
195+
- Sequential calls use **per-call** timeouts, so two ``expect_exact(..., timeout=120)`` lines can behave like a much larger wall-clock budget than a single 120s deadline.
196+
- The **slowest** device should not delay matching on others more than your chosen global timeout.
197197

198198
:class:`~pytest_embedded.group.DutGroup`
199199
========================================
@@ -214,8 +214,7 @@ It is also available as ``Dut.DutGroup`` for discoverability.
214214
expect / expect_exact
215215
---------------------
216216

217-
``expect`` and ``expect_exact`` support both **broadcast** (one pattern for all
218-
DUTs) and **per-DUT** patterns (N patterns for N DUTs), all running in parallel:
217+
``expect`` and ``expect_exact`` support both **broadcast** (one pattern for all DUTs) and **per-DUT** patterns (N patterns for N DUTs), all running in parallel:
219218

220219
.. code:: python
221220
@@ -236,8 +235,7 @@ DUTs) and **per-DUT** patterns (N patterns for N DUTs), all running in parallel:
236235
Other methods
237236
-------------
238237

239-
Any other :class:`~pytest_embedded.dut.Dut` method called on the group is
240-
forwarded with the **same arguments** to every DUT in parallel:
238+
Any other :class:`~pytest_embedded.dut.Dut` method called on the group is forwarded with the **same arguments** to every DUT in parallel:
241239

242240
.. code:: python
243241

pytest-embedded/pytest_embedded/dut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import pexpect
1010

1111
from .app import App
12-
from .log import MessageQueue, PexpectProcess
1312
from .group import DutGroup
13+
from .log import MessageQueue, PexpectProcess
1414
from .unity import UNITY_SUMMARY_LINE_REGEX, TestSuite
1515
from .utils import Meta, _InjectMixinCls, remove_asci_color_code, to_bytes, to_list
1616

pytest-embedded/pytest_embedded/group.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(
4646
# DutGroup class
4747
# ---------------------------------------------------------------------------
4848

49+
4950
class DutGroup:
5051
"""Transparent proxy that forwards method calls to every wrapped
5152
:class:`~pytest_embedded.dut.Dut` **in parallel**.
@@ -129,8 +130,8 @@ def _format_member_head(self, member_index: int) -> str:
129130
gn = self._group_name
130131
name = self._names[member_index]
131132
if gn:
132-
return f"DutGroup {gn!r} member {name!r} (index {member_index})"
133-
return f"DutGroup member {name!r} (index {member_index})"
133+
return f'DutGroup {gn!r} member {name!r} (index {member_index})'
134+
return f'DutGroup member {name!r} (index {member_index})'
134135

135136
def _wrap_member_failure(
136137
self,
@@ -168,10 +169,7 @@ def _run_parallel(
168169

169170
results: list[Any] = [None] * n
170171
executor = ThreadPoolExecutor(max_workers=n)
171-
future_to_idx = {
172-
executor.submit(callables[i], *args_per_call[i], **kwargs_per_call[i]): i
173-
for i in range(n)
174-
}
172+
future_to_idx = {executor.submit(callables[i], *args_per_call[i], **kwargs_per_call[i]): i for i in range(n)}
175173
failed_early = False
176174
try:
177175
for fut in as_completed(future_to_idx):
@@ -205,9 +203,7 @@ def _expect_impl(self, method_name: str, *patterns: Any, **kwargs: Any) -> list[
205203
elif len(patterns) == n:
206204
args_list = [(p,) for p in patterns]
207205
else:
208-
raise ValueError(
209-
f'Expected 1 (broadcast) or {n} (per-DUT) patterns, got {len(patterns)}'
210-
)
206+
raise ValueError(f'Expected 1 (broadcast) or {n} (per-DUT) patterns, got {len(patterns)}')
211207

212208
kwargs_list = [dict(kwargs) for _ in range(n)]
213209
return self._run_parallel(methods, args_list, kwargs_list, operation=method_name)
@@ -250,9 +246,7 @@ def __getattr__(self, name: str) -> Any:
250246
try:
251247
attrs.append(getattr(dut, name))
252248
except AttributeError:
253-
raise AttributeError(
254-
f"'{type(dut).__name__}' object has no attribute '{name}'"
255-
) from None
249+
raise AttributeError(f"'{type(dut).__name__}' object has no attribute '{name}'") from None
256250

257251
if not all(callable(a) for a in attrs):
258252
return attrs

0 commit comments

Comments
 (0)