Metadata-Version: 2.4
Name: saspytest
Version: 0.1.3
Summary: pytest support library for SAS testing with saspy
Project-URL: Homepage, https://github.com/awesome-sas/saspytest
Project-URL: Bug Reports, https://github.com/awesome-sas/saspytest/issues
Project-URL: Source, https://github.com/awesome-sas/saspytest
Author: Andreas Menrath
License-Expression: MIT
License-File: LICENSE
Keywords: assertions,pytest,sas,saspy,testing,unittest
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.11
Requires-Dist: pandas>=3.0.0
Requires-Dist: pytest>=6.0.0
Requires-Dist: saspy>=5.0.0
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pylint; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Requires-Dist: pytest>=6.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# saspytest

**pytest support library for SAS testing with saspy.**

saspytest provides utility functions and pytest-style assertions for testing SAS programs through the [saspy](https://saspy.readthedocs.io/) Python interface. It is inspired by SASUnit assertion macros.

---

## Features

- **Session management** – Shared or isolated SAS sessions with automatic setup and teardown
- **Log assertions** – Validate SAS logs for errors, warnings, or custom patterns
- **Dataset assertions** – Check dataset existence, record counts, columns, and equality
- **Macro assertions** – Verify SAS macro variable values and existence
- **File utilities** – Upload/download files and submit local `.sas` scripts

---

## Installation

```bash
pip install saspytest
```

### Prerequisites

- Python 3.11+
- A working [saspy](https://saspy.readthedocs.io/) configuration that can connect to your SAS deployment
- Java (required by saspy for IOM connections)

> **Note:** saspytest does **not** bundle proprietary SAS JARs. You must provide your own SAS deployment and configure saspy accordingly (e.g. `sascfg_personal.py` or environment variables).

---

## Testing

- Unit tests, no live SAS required: `pytest -c pytest.unit.ini`
- Integration tests, live SAS required: `pytest tests/integration/ -v`

The unit-test config disables the `saspytest` plugin so pytest does not try to open a SAS session during local mock-based runs.

---

## Quickstart

When `saspytest` is installed, pytest auto-loads the package's fixture plugin, so
the `sas_session` fixture is available in your tests without importing it.

```python
from saspytest import (
    assert_no_errors,
    assert_dataset_exists,
    assert_record_count,
)

def test_sas_program(sas_session):
    result = sas_session.submit("""
        data work.SASPYTEST_EXAMPLE;
            do i = 1 to 5;
                output;
            end;
        run;
    """)

    assert_no_errors(result["LOG"])
    assert_dataset_exists(sas_session, "SASPYTEST_EXAMPLE")
    assert_record_count(sas_session, "SASPYTEST_EXAMPLE", 5)
```

---

## Documentation

- **[User Guide](USAGE.md)** – How to use saspytest: session management, assertions, file utilities, and examples
- [API Reference](API_REFERENCE.md) – Complete function and fixture reference
- [Development Setup](DEVELOPMENT.md) – Getting started as a contributor
- [Development Guidelines](DEVELOPMENT_GUIDELINES.md) – Code style and conventions

---

## License

MIT License. See `LICENSE` for details.
