Skip to main content

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 .sas scripts

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)
  • pandas 3.0+ (required by saspytest's get_dataset_as_df() helper)

Note: saspytest does not bundle proprietary SAS JARs. You must provide your own SAS deployment and configure saspy accordingly. sascfg_personal.py is saspy's configuration file; saspytest_config.py is 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


License

MIT License. See LICENSE for details.

Metadata

Release files for saspytest 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for saspytest 1.0.0
File Size Uploaded
saspytest-1.0.0.tar.gz 38.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for saspytest 1.0.0
File Interpreter ABI Platform
saspytest-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 53.0 kB

Release files / saspytest-1.0.0.tar.gz

Download URL saspytest-1.0.0.tar.gz
Size 38.9 kB
Tags Source
SHA-256 checksum
How to use checksums
40b8a7174503fa81002dbdcd016a4c31e6050b1bc96488cc00e55e1854b750ff
BLAKE2b-256 checksum
How to use checksums
cc118a6902846648a09918eab951ba398ca59ff9b08ed3130dceeef3b0c7a437
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 7, 2026.

Transparency log

Release files / saspytest-1.0.0-py3-none-any.whl

Download URL saspytest-1.0.0-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c3b4cdc75398dd4f40506ca95775968949d200debdb5f52871965c1a19739eb
BLAKE2b-256 checksum
How to use checksums
b7acfb4fe59f5f5b26c96f9e56c1a94a92aea179bdbda13971c556cc8fc7abd2
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 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.7

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page