Repository: espressif/pytest-embedded (language: python)

Issue:
pytest-embedded-wokwi doesn't work in Windows (RDT-859)
Following 1383c2e7b8417839a21bc55d171ec807b090f3d6, the plugin no longer works on windows, since the code uses `pexpect.spawn`, which is not available on Windows.

When using pytest-embedded-wokwi on windows, you get the following error:

```
C:\dev\esp\tools\python_env\idf5.4_py3.12_env\Lib\site-packages\pytest_embedded\plugin.py:490: in wrapper
    res = func(*args, **kwargs)
C:\dev\esp\tools\python_env\idf5.4_py3.12_env\Lib\site-packages\pytest_embedded\plugin.py:1139: in wokwi
    return wokwi_gn(**locals())
C:\dev\esp\tools\python_env\idf5.4_py3.12_env\Lib\site-packages\pytest_embedded\dut_factory.py:475: in wokwi_gn   
    return cls(**_drop_none_kwargs(kwargs))
C:\dev\esp\tools\python_env\idf5.4_py3.12_env\Lib\site-packages\pytest_embedded_wokwi\wokwi_cli.py:62: in __init__
    child = pexpect.spawn('wokwi-cli --help')
E   AttributeError: module 'pexpect' has no attribute 'spawn'
```




Discussion / hints:
For anyone else coming across this issue: right now, the workaround is to use an older version on Windows, e.g. version 1.10.3:

```
pip install pytest_embedded_wokwi==1.10.3
```

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index fe1cae8e..ef7454b6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -15,10 +15,10 @@ repos:
       - id: mixed-line-ending
         args: ["-f=lf"]
   - repo: https://github.com/charliermarsh/ruff-pre-commit
-    rev: "v0.4.3"
+    rev: "v0.6.1"
     hooks:
       - id: ruff
-        args: ["--fix", "--preview"]
+        args: ["--fix"]
       - id: ruff-format
         args: ["--preview"]
 
@@ -28,8 +28,8 @@ repos:
     hooks:
       - id: sphinx-lint
         args: [--enable=default-role]
-  - repo: https://github.com/dzhu/rstfmt
-    rev: v0.0.14
+  - repo: https://github.com/hfudev/rstfmt
+    rev: v0.1.4
     hooks:
       - id: rstfmt
         args: ["-w", "-1"]
@@ -37,7 +37,7 @@ repos:
 
   # git commit
   - repo: https://github.com/espressif/conventional-precommit-linter
-    rev: v1.8.0
+    rev: v1.10.0
     hooks:
       - id: conventional-precommit-linter
         stages: [commit-msg]


Test patch:
diff --git a/pytest-embedded-idf/pytest_embedded_idf/unity_tester.py b/pytest-embedded-idf/pytest_embedded_idf/unity_tester.py
index d9047cfe..fcfef146 100644
--- a/pytest-embedded-idf/pytest_embedded_idf/unity_tester.py
+++ b/pytest-embedded-idf/pytest_embedded_idf/unity_tester.py
@@ -828,7 +828,7 @@ def __init__(self, dut: t.Union['IdfDut', t.List['IdfDut']]) -> None:  # type: i
         """
         if isinstance(dut, Iterable):
             self.is_multi_dut = True
-            self.dut: t.List['IdfDut'] = list(dut)
+            self.dut: t.List[IdfDut] = list(dut)
             self.first_dut = self.dut[0]
             self.test_menu = self.first_dut.test_menu
         else:
diff --git a/pytest-embedded-wokwi/pytest_embedded_wokwi/wokwi_cli.py b/pytest-embedded-wokwi/pytest_embedded_wokwi/wokwi_cli.py
index 4315a189..a1e388af 100644
--- a/pytest-embedded-wokwi/pytest_embedded_wokwi/wokwi_cli.py
+++ b/pytest-embedded-wokwi/pytest_embedded_wokwi/wokwi_cli.py
@@ -1,11 +1,12 @@
 import json
 import logging
 import os
+import re
 import shutil
+import subprocess
 import typing as t
 from pathlib import Path
 
-import pexpect
 import toml
 from packaging.version import Version
 from pytest_embedded import __version__
@@ -59,11 +60,10 @@ def __init__(
         if shutil.which('wokwi-cli') is None:
             raise RuntimeError('Please install wokwi-cli, by running: curl -L https://wokwi.com/ci/install.sh | sh')
 
-        child = pexpect.spawn('wokwi-cli --help')
+        output = subprocess.check_output(['wokwi-cli', '--help'])
         try:
-            child.expect(r'Wokwi CLI v(\d+\.\d+\.\d+)', timeout=1)
-            wokwi_cli_version = child.match.group(1).decode('utf-8')
-        except pexpect.TIMEOUT:
+            wokwi_cli_version = re.match(r'Wokwi CLI v(\d+\.\d+\.\d+)', output.decode('utf-8')).group(1)
+        except AttributeError:
             logging.warning('Failed to get wokwi-cli version, assume version requirements satisfied')
         else:
             if Version(wokwi_cli_version) < Version(WOKWI_CLI_MINIMUM_VERSION):