pytest-embedded 2.2.0__tar.gz → 2.2.1__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.2.0
3
+ Version: 2.2.1
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.2.0'
9
+ __version__ = '2.2.1'
@@ -838,3 +838,16 @@ class DutFactory:
838
838
  _close_or_terminate(obj)
839
839
  del layout
840
840
  raise e
841
+
842
+ @classmethod
843
+ def get_all_duts(cls) -> list[Dut]:
844
+ """Get all DUTs created by DutFactory."""
845
+
846
+ duts = []
847
+ for layout in cls.obj_stack:
848
+ # The DUT is always the last object in the layout
849
+ dut = layout[-1]
850
+ if isinstance(dut, Dut):
851
+ duts.append(dut)
852
+
853
+ return duts
@@ -1372,10 +1372,18 @@ class PytestEmbedded:
1372
1372
 
1373
1373
  @pytest.hookimpl(trylast=True)
1374
1374
  def pytest_runtest_call(self, item: Function):
1375
- # raise dut failed cases
1375
+ all_duts: list[Dut] = []
1376
+
1377
+ # Check DUTs created by fixture
1376
1378
  if 'dut' in item.funcargs:
1377
- duts = [dut for dut in to_list(item.funcargs['dut']) if isinstance(dut, Dut)]
1378
- self._raise_dut_failed_cases_if_exists(duts) # type: ignore
1379
+ fixture_duts = [dut for dut in to_list(item.funcargs['dut']) if isinstance(dut, Dut)]
1380
+ all_duts.extend(fixture_duts)
1381
+
1382
+ # Check DUTs created by DutFactory
1383
+ factory_duts = DutFactory.get_all_duts()
1384
+ all_duts.extend(factory_duts)
1385
+
1386
+ self._raise_dut_failed_cases_if_exists(all_duts) # type: ignore
1379
1387
 
1380
1388
  @pytest.hookimpl(trylast=True) # combine all possible junit reports should be the last step
1381
1389
  def pytest_sessionfinish(self, session: Session, exitstatus: int) -> None:
File without changes