{
  "id": "ros2/colcon-test-no-pytest-framework",
  "signature": "colcon test: Failed to find pytest framework for package 'my_package'",
  "signature_zh": "colcon test：未找到包 'my_package' 的 pytest 框架",
  "regex": "colcon test: Failed to find (pytest|unittest) framework for package '([^']+)'",
  "domain": "ros2",
  "category": "test_error",
  "subcategory": null,
  "root_cause": "colcon test requires a test framework (pytest or unittest) to be configured in setup.cfg or package.xml; missing or misconfigured entry causes test discovery failure.",
  "root_cause_type": "generic",
  "root_cause_zh": "colcon test 需要在 setup.cfg 或 package.xml 中配置测试框架（pytest 或 unittest）；缺少或配置错误会导致测试发现失败。",
  "versions": [
    {
      "version": "ros2:humble",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ros2:iron",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "colcon-core:0.14.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pytest:7.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reinstalling pytest with pip without checking package configuration",
      "why_fails": "pytest is already installed; the issue is in the package's test configuration, not the framework itself.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding a dummy test file without updating setup.cfg",
      "why_fails": "colcon uses setup.cfg or package.xml to discover tests; a test file alone is insufficient.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Running pytest directly instead of colcon test",
      "why_fails": "pytest may work locally but colcon test uses a different discovery mechanism; this doesn't fix the colcon integration.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure setup.cfg in the package root contains a [tool:pytest] section and test paths are listed. Example:\n[tool:pytest]\ntestpaths = test\n\nThen run: colcon test --packages-select my_package",
      "success_rate": 0.85,
      "how": "Ensure setup.cfg in the package root contains a [tool:pytest] section and test paths are listed. Example:\n[tool:pytest]\ntestpaths = test\n\nThen run: colcon test --packages-select my_package",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a test_depend entry for pytest in package.xml and ensure a conftest.py or __init__.py exists in the test directory:\n<test_depend>python3-pytest</test_depend>\n\nThen rebuild: colcon build --packages-select my_package && colcon test",
      "success_rate": 0.8,
      "how": "Add a test_depend entry for pytest in package.xml and ensure a conftest.py or __init__.py exists in the test directory:\n<test_depend>python3-pytest</test_depend>\n\nThen rebuild: colcon build --packages-select my_package && colcon test",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保包根目录下的 setup.cfg 包含 [tool:pytest] 部分并列出测试路径。示例：\n[tool:pytest]\ntestpaths = test\n\n然后运行：colcon test --packages-select my_package",
    "在 package.xml 中添加 pytest 的 test_depend 条目，并确保 test 目录中存在 conftest.py 或 __init__.py：\n<test_depend>python3-pytest</test_depend>\n\n然后重新构建：colcon build --packages-select my_package && colcon test"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros.org/en/humble/Tutorials/Intermediate/Testing/Testing-Main.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}