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.5.tar.gz (29.3 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.5-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: saspytest-0.1.5.tar.gz
  • Upload date:
  • Size: 29.3 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.5.tar.gz
Algorithm Hash digest
SHA256 6f2efc4070f6a1ab39449d1de95db142ce70808d933f46c66d7b42574b5d1ed1
MD5 cb9ba08461f310806b60b67c0e7de9bb
BLAKE2b-256 55d91965fb66591c27b2c81efd10d566df36c005de5cad781405595269380f04

See more details on using hashes here.

Provenance

The following attestation bundles were made for saspytest-0.1.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: saspytest-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f5dadd3717504dbdd58e2b08d686c82bde999d32143817665909f991778baa99
MD5 f6904a283c3be66eaf44da9b6bdad05a
BLAKE2b-256 6d8250fe0f0ef44d335075eff747a525507c426908f6d1c6ee2111699bcd3013

See more details on using hashes here.

Provenance

The following attestation bundles were made for saspytest-0.1.5-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