一键导入
add-test
// Add unit and integration tests for Prompture functionality. Uses pytest conventions, shared fixtures from conftest.py, and the integration marker pattern. Use when writing tests for new or existing features.
// Add unit and integration tests for Prompture functionality. Uses pytest conventions, shared fixtures from conftest.py, and the integration marker pattern. Use when writing tests for new or existing features.
| name | add-test |
| description | Add unit and integration tests for Prompture functionality. Uses pytest conventions, shared fixtures from conftest.py, and the integration marker pattern. Use when writing tests for new or existing features. |
| metadata | {"author":"prompture","version":"1.0"} |
Creates tests in tests/ following project conventions.
tests/conftest.pyDEFAULT_MODEL (currently "ollama/gpt-oss:20b")@pytest.mark.integration (skipped by default)# Fixtures
sample_json_schema # {"name": str, "age": int, "interests": list}
integration_driver # Driver from DEFAULT_MODEL (skips if unavailable)
# Assertion helpers
assert_valid_usage_metadata(meta) # Checks prompt_tokens, completion_tokens, total_tokens, cost, raw_response
assert_jsonify_response_structure(response) # Checks json_string, json_object, usage
tests/test_{module}.py — maps to source moduletests/test_{feature}.py — cross-cutting featuresimport pytest
from prompture import extract_with_model
class TestFeatureName:
"""Tests for {feature}."""
def test_basic_behavior(self):
"""What this test verifies."""
result = some_function(...)
assert result["key"] == expected
def test_error_handling(self):
"""Should raise ValueError on invalid input."""
with pytest.raises(ValueError, match="expected"):
some_function(bad_input)
class TestFeatureIntegration:
"""Integration tests requiring live LLM access."""
@pytest.mark.integration
def test_live_extraction(self, integration_driver, sample_json_schema):
result = extract_and_jsonify(
text="John is 30 years old",
json_schema=sample_json_schema,
model_name=DEFAULT_MODEL,
)
assert_jsonify_response_structure(result)
assert_valid_usage_metadata(result["usage"])
@pytest.mark.integrationpytest tests/ -x -q # Unit only
pytest tests/ --run-integration -x -q # Include integration
pytest tests/test_core.py::TestClass::test_method # Single test
Update LLM model pricing in Prompture. Pricing resolves through a pluggable source registry — by default local KB JSON files (primary, curated) then models.dev (fallback). Use when model prices change, new models launch, models.dev data is stale, or you need to add a custom pricing source.
Scaffold a new LLM provider driver for Prompture. Creates sync + async driver classes, registers them in the driver registry, adds settings, env template, setup.py extras, package exports, discovery integration, and models.dev pricing. Use when adding support for a new LLM provider.
Create a new Prompture usage example script. Follows project conventions for file naming, section structure, docstrings, and output formatting. Use when demonstrating extraction use cases or provider integrations.
Create reusable persona system prompts for Prompture. Covers Persona dataclass, template variables, composition, trait registry, global registry, serialization, and Conversation integration. Use when defining system prompts for extraction or agent behavior.
Add function-calling tools to Prompture agents. Covers ToolDefinition, ToolRegistry, tool_from_function, decorator patterns, serialization formats, and Conversation integration. Use when adding callable tools for LLM function calling.
Add predefined field definitions to the Prompture field registry. Handles field structure, categories, template variables, enum support, and thread-safe registration. Use when adding reusable extraction fields.