{"id":21803,"library":"pytest-embedded","title":"pytest-embedded","description":"A pytest plugin designed for embedded system testing. Current version 2.7.0 provides fixtures and utilities for testing firmware on microcontrollers and SoCs, with support for serial, jtag, and qemu backends. Release cadence is irregular, with recent updates focused on compatibility with pytest 8+.","status":"active","version":"2.7.0","language":"python","source_language":"en","source_url":"https://github.com/espressif/pytest-embedded","tags":["embedded","testing","pytest-plugin","esp32"],"install":[{"cmd":"pip install pytest-embedded","lang":"bash","label":"Basic install"},{"cmd":"pip install 'pytest-embedded[serial]'","lang":"bash","label":"With serial support"},{"cmd":"pip install 'pytest-embedded[qemu]'","lang":"bash","label":"With QEMU support"},{"cmd":"pip install 'pytest-embedded[all]'","lang":"bash","label":"All extras"}],"dependencies":[{"reason":"Required: pytest plugin","package":"pytest","optional":false},{"reason":"Serial backend","package":"pyserial","optional":true},{"reason":"ELF parsing for firmware","package":"pyelftools","optional":true}],"imports":[{"note":"Import directly; no subpackage needed.","wrong":"from embedded import pytest_embedded","symbol":"pytest_embedded","correct":"import pytest_embedded"}],"quickstart":{"code":"import pytest\nimport os\n\n# conftest.py\ndef pytest_embedded_config():\n    return {\n        'app': os.environ.get('APP_PATH', '.'),\n        'port': os.environ.get('TARGET_PORT', '/dev/ttyUSB0'),\n        'target': os.environ.get('TARGET', 'esp32'),\n    }\n\n# test_example.py\ndef test_basic(dut):\n    dut.expect('Hello from firmware')\n    dut.write('test_cmd')\n    dut.expect('ok', timeout=5)","lang":"python","description":"Basic example with DUT fixture. Requires conftest.py defining pytest_embedded_config."},"warnings":[{"fix":"Rename to `pytest_embedded_config`.","message":"In v2.x, the config function must be named `pytest_embedded_config`, not `pytest_embedded_conf` as in v1.x.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use `--target` instead.","message":"The `--embedded-boards` CLI option is deprecated in favor of `--target`.","severity":"deprecated","affected_versions":">=1.5.0 <=2.5.0"},{"fix":"Use the DUT fixture's read/write methods instead of raw pexpect.","message":"If you use `pexpect` directly on the DUT, it may conflict with the internal serial handling; use `dut.write()` and `dut.expect()` methods.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install pytest-embedded` in the correct virtual environment.","cause":"Package not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'pytest_embedded'"},{"fix":"Upgrade to v2.x: `pip install 'pytest-embedded>=2'` and use `dut.expect()`.","cause":"Using v1.x API where DUT has different method names.","error":"AttributeError: 'Dut' object has no attribute 'expect'"},{"fix":"Ensure `pytest_embedded_config` returns a dict with required keys (app, port, target).","cause":"Config function not returning a dictionary as expected.","error":"TypeError: pytest_embedded_config() missing 1 required positional argument: 'app'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}