Metadata-Version: 2.4
Name: pysnappea
Version: 0.1.0
Classifier: Framework :: Pytest
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Testing
Requires-Dist: tomli>=1.1 ; python_full_version < '3.11'
Summary: Check P specs against events from your Python tests
License: MIT OR Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://github.com/crowecawcaw/snappea/blob/main/docs/python.md
Project-URL: Repository, https://github.com/crowecawcaw/snappea

# Snap Pea for Python

Check [P](https://p-org.github.io/P/) specs against events your code emits during its
ordinary tests. The package brings the `snappea` binary, so `pip install pysnappea` is the whole
setup.

```python
from snappea import emit

def grant(self, client, lock):
    ...
    emit("eEnter", key=lock, client=client)
```

```toml
# pyproject.toml
[tool.snappea]
spec_files = ["specs/*.p"]
```

Every pytest test now also checks every spec in `specs/`. Or check selected tests
explicitly:

```python
from snappea import check_spec

def test_lease_expiry():
    with check_spec("MutualExclusion"):
        ...
```

In production, `snappea.set_sink("/var/log/app/events.jsonl")` sends the same events to a
log that `snappea observe` checks. See
[docs/python.md](https://github.com/crowecawcaw/snappea/blob/main/docs/python.md) and
[Testing and production](https://github.com/crowecawcaw/snappea/blob/main/docs/production.md).

