Metadata-Version: 2.4
Name: pytest-agentest
Version: 0.2.0
Summary: pytest helpers for AiEnsured agentest, an Agentic AI Testing platform. The pytest plugin ships inside agentest-ai 3.8.0 and later; this package depends on it and keeps the 0.1.0 options.
Author-email: Dr Srinivas Padmanabhuni <srinivas@testaing.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/srpadmanabhuni/pytest-agentest
Project-URL: Documentation, https://github.com/srpadmanabhuni/agentest/blob/main/docs/integrations/pytest.md
Project-URL: Source, https://github.com/srpadmanabhuni/pytest-agentest
Keywords: pytest,plugin,agentest,agentic-evals,opentelemetry
Classifier: Framework :: Pytest
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: agentest-ai>=3.8
Requires-Dist: pytest>=7.0
Dynamic: license-file

# pytest-agentest

pytest support for AiEnsured agentest, an Agentic AI Testing platform.

**The pytest plugin ships inside `agentest-ai` 3.8.0 and later.** Install `agentest-ai` and you have the `agentest` marker, the `agentest_trace` and `agentest_record` fixtures and `assert_checks`. This package depends on `agentest-ai>=3.8`, so installing it brings the plugin with it, and it keeps the command-line options and the `agentest_run` fixture from 0.1.0.

## Install

```
pip install agentest-ai
```

Or, to keep the 0.1.0 options as well:

```
pip install pytest-agentest
```

## Use the plugin that ships in agentest-ai

```python
import pytest

@pytest.mark.agentest(trace="traces/refund.otlp.jsonl", card="agent-card.json", tools="tools.json", checks=["T1-005", "T1-018"])
def test_refund_run():
    pass
```

The full guide, with the fixtures and the recorder, is at https://github.com/srpadmanabhuni/agentest/blob/main/docs/integrations/pytest.md

## What this package adds (from 0.1.0, unchanged)

Call agentest from a test with the `agentest_run` fixture:

```python
def test_recorded_trace(agentest_run):
    result = agentest_run(otlp="traces/run.otlp.jsonl", ids="T1-018", fmt="md")
    assert result.returncode == 0
```

Or pass traces on the command line. With `--agentest-strict`, pytest fails if any check fails:

```
pytest --agentest-otlp traces/run.otlp.jsonl --agentest-ids T1-018 --agentest-strict
```

- `--agentest-otlp PATH`: OTLP trace file (repeatable)
- `--agentest-ids IDS`: limit to test IDs or classes, comma-separated (for example `T1-018`)
- `--agentest-strict`: fail the pytest session if any agentest check fails

## Changes in 0.2.0

- Depends on `agentest-ai>=3.8`.
- Registers its plugin under the entry-point name `agentest_cli`. In 0.1.0 it used the name `agentest`, which is also the name of the plugin inside `agentest-ai` 3.8.0, so pytest loaded only one of the two and the `--agentest-otlp`, `--agentest-ids` and `--agentest-strict` options could be missing. Both plugins now load together.

## Links

- PyPI (agentest): https://pypi.org/project/agentest-ai/
- Plugin repo: https://github.com/srpadmanabhuni/pytest-agentest
- agentest repo: https://github.com/srpadmanabhuni/agentest
- Docs: https://srpadmanabhuni.github.io/agentest/
