saspytest
pytest support library for SAS testing with saspy.
saspytest provides utility functions and pytest-style assertions for testing SAS programs through the saspy 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
.sasscripts
Installation
pip install saspytest
With uv, use uv add saspytest in a uv-managed
project, or uv pip install saspytest in an existing environment.
Prerequisites
- Python 3.11+
- A working saspy configuration that can connect to your SAS deployment
- Java (required by saspy only for IOM connections)
Note: saspytest does not bundle proprietary SAS JARs. You must provide your own SAS deployment and configure saspy accordingly.
sascfg_personal.pyis saspy's configuration file;saspytest_config.pyis saspytest's separate auto-discovered project configuration convention. See Getting Started.
Getting Started
The normal saspytest workflow is to write pytest tests that execute SAS code against a live SAS session. See the Getting Started guide.
Run a user test project with:
pytest -v
The repository's mock-based unit tests are internal contributor tests. They do not require SAS and are documented in Contributing.
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. The
example requires a live SAS connection. If a project also contains SAS-free
Python tests, use the optional live-SAS test marker.
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
- Getting Started – Configure SAS execution environment and write your first live-SAS test
- User Guide – How to use saspytest: session management, assertions, file utilities, and examples
- API Reference – Complete function and fixture reference
- Development Setup – Getting started as a contributor
- Development Guidelines – Code style and conventions
- AI Skills – Agent skills available in this repository (e.g.
sas-tester)
License
MIT License. See LICENSE for details.
Metadata
Release files for saspytest 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| saspytest-0.1.7.tar.gz | 37.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| saspytest-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.6 kB
Release files / saspytest-0.1.7.tar.gz
| Download URL | saspytest-0.1.7.tar.gz |
|---|---|
| Size | 37.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
475f7c46a0acf4743708536a0d789ea221df8962291530c60fa1ddccf1d7fcc2
|
|
BLAKE2b-256 checksum How to use checksums |
aa637ff0e8b7bb7607f5769ca020c53c8ccdddbda9077cb2368d7e8c399dfa71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / saspytest-0.1.7-py3-none-any.whl
| Download URL | saspytest-0.1.7-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0d855410c27143ee05c0827192d2296f728876a3796b681e8ae777f88b77cfc
|
|
BLAKE2b-256 checksum How to use checksums |
747b4606603d84282ef1289ed24defb9401e7329fd181285b74a41f5f0f70cc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency log