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.4.tar.gz (26.8 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.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: saspytest-0.1.4.tar.gz
  • Upload date:
  • Size: 26.8 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.4.tar.gz
Algorithm Hash digest
SHA256 c8949d2fdb3684aafbade8b6f7208f71a2c6d1b22bd66973949ca168569a3582
MD5 452e430d0e9a0da1e2fddeced18222b3
BLAKE2b-256 0f43299c32c431581bfa14d0db525b1363e35af03950463c7bb8e4e8d7ca70cb

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: saspytest-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 69ad8c07b124bc99c5a076f5cc6abcb905c1418cdd842132fcc6a5171046e00b
MD5 175eea2b4f6406a0e5e6c4eb26baa63f
BLAKE2b-256 716524273d350453e158e26e06538fa236a7e324acf75b2b5d74fa579a03808a

See more details on using hashes here.

Provenance

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