Skip to content

Configure Pytest

Adapter status: ⛔ STUB. The Pytest adapter is documented but not implemented. pytest is a valid value in qa-stack.yaml and lippia-neo-bootstrap-stack detects it, but the skills that need the adapter stop as soon as they start:

Adapter pytest en estado STUB.
Ver <skill_root>/adapters/pytest/STUB.md para contribuir.
Value in qa-stack.yaml test_framework: pytest
Language python
Intended app type Mainly api. Pytest has no browser of its own, and the pytest-playwright case isn't covered
Default tests folder tests/pytest/

1. What works today and what doesn't

Skill Does it work with test_framework: pytest?
lippia-neo-bootstrap-stack ✅ Detects Pytest (pyproject.toml, setup.cfg, or requirements.txt with pytest) and generates qa-stack.yaml
lippia-neo-read-user-story, lippia-neo-create-test-plan, and the rest of the skills that don't touch test code ✅ They don't depend on the framework
lippia-neo-generate-test-suite ⛔ Stops: it can't generate tests
lippia-neo-run-and-heal ⛔ Stops: it can't run or fix tests
Playbooks that generate or run tests (Feature End-to-End, Bug Fix Cycle, Smoke Test, Hotfix…) ⛔ They stop at the first step that uses those skills

In the meantime: if what you need is to test an API, the Playwright adapter generates and runs API tests (app_type: api) without a browser. See Configure Playwright.


2. Get the project ready

If your project is Python and you want to have it ready for when the adapter is implemented, you can generate qa-stack.yaml right now:

stack:
  test_framework: pytest
  language: python
  app_type: api
  auth: api_token
  pipeline_provider: gitlab

environment:
  base_url: https://api.techstore-staging.com
  app_version: sprint-24
  os: Ubuntu 22.04

api_contract:
  spec_path: openapi.yaml
  spec_url: null

paths:
  user_stories_storage:
    type: local
    cloud_provider_mcp: null
    local_path: user-stories/
  test_plans_dir: test-plans/
  tests_dir: tests/pytest/
  reports_dir: test-results/
  env_file: .env.tests

commands:
  run_tests: pytest --junitxml=test-results/results.xml
  install_deps: pip install -r requirements.txt

And have installed:

Tool Intended version
Python 3.9 or higher
pytest —
pytest-json-report To generate the JSON that parse-results.sh will read
httpx (or requests) For the API tests
pip install pytest pytest-json-report httpx

3. How it will work (intended design)

According to the contract documented in each skill's STUB.md, once the adapter is implemented:

Aspect Intended design
Generated files tests/<US-ID>/test_tc_NN_<slug>.py, with functions in snake_case
Authentication conftest.py fixtures with httpx.Client: one with the manager token and another with the viewer token
Credentials Through environment variables (API_BASE_URL, API_TOKEN_MANAGER, API_TOKEN_VIEWER, QA_API_TOKEN), never literals
Cleanup An autouse=True fixture that deletes the resources created by the tests
Assertions Standard Python assert
Run command pytest <tests_dir> --junitxml=test-results/results.xml --json-report --json-report-file=test-results/results.json -v
Results parse-results.sh converts test-results/results.json to NEO's common format

Example of the intended template for an API test:

import os
import pytest
import httpx

BASE_URL = os.environ["API_BASE_URL"]
TOKEN_MANAGER = os.environ["API_TOKEN_MANAGER"]

@pytest.fixture
def manager_client():
    headers = {"Authorization": f"Bearer {TOKEN_MANAGER}", "Content-Type": "application/json"}
    with httpx.Client(base_url=BASE_URL, headers=headers) as client:
        yield client

def test_tc_01_crear_orden_happy_path(manager_client):
    response = manager_client.post("/orders/v1", json={"product_id": 42, "quantity": 1})
    assert response.status_code == 201

4. What's missing to complete it

For anyone who wants to contribute to the skills repository, these need to be created:

Skill Files to create in adapters/pytest/
lippia-neo-generate-test-suite README.md (conventions), test-template.py (API test template), and conftest-template.py (shared fixtures)
lippia-neo-run-and-heal run.sh (runs pytest), parse-results.sh (converts the pytest-json-report JSON to the common format), and README.md

Once the README.md exists in the adapter folder, the skills stop treating it as a STUB and use it like any other. The full details are in skills/lippia-neo-generate-test-suite/adapters/pytest/STUB.md and skills/lippia-neo-run-and-heal/adapters/pytest/STUB.md in the skills repository.


5. Common problems (and what to do)

What you see Why it happens What to do
Adapter pytest en estado STUB The adapter isn't implemented yet Use Playwright for API tests in the meantime, or contribute the adapter (section 4)
A playbook stops when generating or running tests All playbooks use lippia-neo-generate-test-suite or lippia-neo-run-and-heal Same as the previous case