pytest-embedded 2.9.1__tar.gz → 2.9.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-embedded
3
- Version: 2.9.1
3
+ Version: 2.9.3
4
4
  Summary: A pytest plugin that designed for embedded testing.
5
5
  Author-email: Fu Hanxi <fuhanxi@espressif.com>
6
6
  Requires-Python: >=3.10
@@ -6,4 +6,4 @@ from .dut_factory import DutFactory
6
6
 
7
7
  __all__ = ['App', 'Dut', 'DutFactory']
8
8
 
9
- __version__ = '2.9.1'
9
+ __version__ = '2.9.3'
@@ -1349,16 +1349,19 @@ def dut(
1349
1349
  @pytest.fixture
1350
1350
  def unity_tester(dut: t.Union['IdfDut', tuple['IdfDut']]) -> t.Optional['CaseTester']:
1351
1351
  try:
1352
- from pytest_embedded_idf import CaseTester, IdfDut
1352
+ from pytest_embedded_idf import CaseTester
1353
+ from pytest_embedded_idf.unity_tester import IdfUnityDutMixin
1353
1354
  except ImportError:
1354
1355
  yield None
1355
1356
  else:
1356
- # all dut instance must be IdfDut to use this fixture
1357
- for _dut in to_list(dut):
1358
- if not isinstance(_dut, IdfDut):
1359
- yield None
1360
-
1361
- yield CaseTester(to_list(dut))
1357
+ duts = to_list(dut)
1358
+ # `CaseTester` drives the unity test menu, which every dut carrying
1359
+ # `IdfUnityDutMixin` provides: `IdfDut` inherits it, and the dut factory
1360
+ # mixes it into the qemu and esp-emu duts when the idf service is used.
1361
+ if all(isinstance(_dut, IdfUnityDutMixin) for _dut in duts):
1362
+ yield CaseTester(duts)
1363
+ else:
1364
+ yield None
1362
1365
 
1363
1366
 
1364
1367
  ##################
@@ -334,20 +334,27 @@ def test_expect(testdir):
334
334
  def test_expect_from_timeout(testdir):
335
335
  testdir.makepyfile(r"""
336
336
  import threading
337
- import time
338
337
  import pexpect
339
338
 
340
339
  def test_expect_from_timeout(msg_queue, dut):
340
+ stop = threading.Event()
341
+
341
342
  def write_bytes():
342
343
  for _ in range(5):
344
+ if stop.is_set():
345
+ return
343
346
  msg_queue.write('1')
344
- time.sleep(1.5)
347
+ stop.wait(1.5)
345
348
 
346
349
  write_thread = threading.Thread(target=write_bytes, daemon=True)
347
350
  write_thread.start()
348
351
 
349
- res = dut.expect(pexpect.TIMEOUT, timeout=4)
350
- assert res == b'111'
352
+ try:
353
+ res = dut.expect(pexpect.TIMEOUT, timeout=4)
354
+ assert res == b'111'
355
+ finally:
356
+ stop.set()
357
+ write_thread.join(timeout=2)
351
358
  """)
352
359
 
353
360
  result = testdir.runpytest('-s')
File without changes