Skip to main content

pytest support library for SAS testing with saspy

Project description

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

Prerequisites

  • Python 3.11+
  • A working saspy 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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saspytest-0.1.3.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saspytest-0.1.3-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file saspytest-0.1.3.tar.gz.

File metadata

  • Download URL: saspytest-0.1.3.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for saspytest-0.1.3.tar.gz
Algorithm Hash digest
SHA256 992a8a3924265dae6f7183b2ae805d87534bfe61248d13e83308c75a6c4089f0
MD5 ec2263072819f061416bd202e6b88f4e
BLAKE2b-256 b247180671b0106bc14cd0a47042215fb9079143306781cf4217aca74815d88d

See more details on using hashes here.

Provenance

The following attestation bundles were made for saspytest-0.1.3.tar.gz:

Publisher: release.yml on awesome-sas/saspytest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file saspytest-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: saspytest-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for saspytest-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 742ca40a6564ed0d7f294fdbd9d5eed1235ac7bc4f62ffeeb62cd8686f4daf00
MD5 820f3c77b6c60fd89e6a4d882620a6c9
BLAKE2b-256 e13a5675876124634df26f7ef049d40cc954f8b37c5871e8a6249b930ce83ef8

See more details on using hashes here.

Provenance

The following attestation bundles were made for saspytest-0.1.3-py3-none-any.whl:

Publisher: release.yml on awesome-sas/saspytest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page