콘텐츠로 이동

Pytest Operation


Pytest executes Fixture-based CT Test Cases in mock or hil mode. After execution, the Report operation uses a Local LLM to analyze the result and generate Markdown.


Framework structure and Fixture contracts are documented in Pytest CT Framework.


Operation Summary


Item Pytest operation
Test unit One CT Test Case
Primary identifier TEST ID, such as CT-UART-001
Test composition Numbered Fixture with interfaces and equipment
Runtime mode mock or hil
Result capture test_envs/tests/pytest/conftest.py
Local LLM Used during Report generation
Coverage pytest-cov or VS Code Testing Coverage


Execution Sequence


Collect CT Test Cases
        ↓
Validate TEST ID, Fixture ID, marker, and Fixture metadata
        ↓
Apply optional --test-id selection
        ↓
Resolve mock or hil mode
        ↓
Connect Fixture interfaces and equipment
        ↓
Execute Test Case and record metrics/statistics
        ↓
Disconnect Fixture resources
        ↓
Write Result JSON and Test Log


Step Operation
1 Pytest collects test_envs/tests/pytest/test_cases
2 conftest.py validates the CT marker and numbered Fixture contract
3 --test-id keeps one TEST ID when provided
4 --fixture-mode overrides the marker or uses its default mode
5 The Fixture connects its interface and equipment before yield
6 The Test Case executes assertions and updates ct_result
7 Fixture cleanup disconnects resources in reverse order
8 The result hook stores normalized evidence by TEST ID and Execution ID


marker is a mode-selection instruction, not a final execution mode. It resolves to the mock or hil value declared by @pytest.mark.ct.


Run Pytest


Run every configured test:


.\.venv\Scripts\python.exe -m pytest


Run all CT Test Cases with their marker modes:


.\.venv\Scripts\python.exe -m pytest test_envs/tests/pytest/test_cases --fixture-mode=marker


Force Mock mode:


.\.venv\Scripts\python.exe -m pytest test_envs/tests/pytest/test_cases --fixture-mode=mock


Run one TEST ID:


.\.venv\Scripts\python.exe -m pytest test_envs/tests/pytest/test_cases --test-id CT-UART-001 --fixture-mode=mock


The current executable CT Test Cases use Mock implementations. Selecting HIL fails explicitly where a physical Fixture implementation has not been completed.


Test Coverage


Run CT Test Cases and print missing Python lines:


.\.venv\Scripts\python.exe -m pytest test_envs/tests/pytest/test_cases --fixture-mode=mock --cov=test_envs --cov-report=term-missing


pytest-cov stores coverage data in .coverage. Add --cov-report=html when an HTML report under htmlcov/ is needed.


In VS Code Testing, select a Pytest node and use Run Test with Coverage. Coverage measures executed Python code; it does not measure physical HIL signal or protocol coverage.


Result and Report


Pytest execution and Report generation are separate operations.


Pytest execution
      ↓
Result JSON + Test Log
      ↓
test_envs.tools.test_result
      ↓
Local LLM analysis
      ↓
Conditional escalation decision
      ↓
Canonical Markdown
      ├── MkDocs Results
      └── Pandoc Report


Output Path
Result JSON test_reports/results/pytest/test_cases/<test-id>/<execution-id>_result.json
Test log test_reports/results/pytest/test_cases/<test-id>/<execution-id>_test.log
Local LLM log test_reports/local_llm/<execution-id>_local_llm.log
Canonical Markdown test_reports/markdown/pytest/test_cases/<test-id>/<execution-id>_result.md
MkDocs result docs/tests/pytest/
Pandoc output test_reports/pandocs/pytest/test_cases/<test-id>/
DOCX reference test_reports/pandocs/reference.docx


Generate every pending Markdown report and publish MkDocs result pages:


.\.venv\Scripts\python.exe -m test_envs.tools.test_result --pending --docs


If Ollama is unavailable or returns invalid analysis, the reporter records the attempts and uses deterministic fallback analysis so Report generation can continue.


See Pytest Results for published results.