Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

CI Docs Codecov Python Versions Python Wheel Code Style: black PyPI - License

What is Pytest Shell Utilities

“When in doubt, shell out”

—Thomas S. Hatch

This pytest plugin was extracted from pytest-salt-factories. If provides a basic fixture shell which basically uses subprocess.Popen to run commands against the running system on a shell while providing a nice assert’able return class.

Install

Installing pytest-shell-utilities is as simple as:

python -m pip install pytest-shell-utilities

And, that’s honestly it.

Usage

Once installed, you can now use the shell fixture to run some commands and assert against the outcome.

def test_assert_good_exitcode(shell):

    ret = shell.run("exit", "0")
    assert ret.returncode == 0

def test_assert_bad_exitcode(shell):

    ret = shell.run("exit", "1")
    assert ret.returncode == 1

If the command outputs parseable JSON, the shell fixture can attempt loading that output as JSON which allows for asserting against the JSON loaded object.

def test_against_json_output(shell):
   d = {"a", "a", "b": "b"}
   ret = shell.run("echo", json.dumps(d))
   assert ret.data == d

Documentation

The full documentation can be seen here.

Download files

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

Source Distribution

pytest-shell-utilities-1.0.0rc3.tar.gz (90.6 kB view details)

Uploaded Source

Built Distribution

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

pytest_shell_utilities-1.0.0rc3-py3-none-any.whl (44.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest-shell-utilities-1.0.0rc3.tar.gz.

File metadata

  • Download URL: pytest-shell-utilities-1.0.0rc3.tar.gz
  • Upload date:
  • Size: 90.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

File hashes

Hashes for pytest-shell-utilities-1.0.0rc3.tar.gz
Algorithm Hash digest
SHA256 635cc03654b46dba7bef17a3f54a135eb35c18388b7bd2572177474d7afb95c9
MD5 6aa1971cd35bc24e96f8615a1aa06160
BLAKE2b-256 2461be4eb1f90768ef0c2262a40fb6c43274e3e811b006935208e921230852db

See more details on using hashes here.

File details

Details for the file pytest_shell_utilities-1.0.0rc3-py3-none-any.whl.

File metadata

  • Download URL: pytest_shell_utilities-1.0.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 44.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

File hashes

Hashes for pytest_shell_utilities-1.0.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 b03f6097781e2897538f2fa77860648b166764371af93277b6229d3c78433ceb
MD5 85a8dd5e84310e1b4cd7856fce70f502
BLAKE2b-256 aac0800a973983486f056ff077b3924e01c7de9b86d3dccc20582ad53cc2f56d

See more details on using hashes here.

Release history Release notifications | RSS feed

1.9.7

2 files

1.9.6

2 files

1.9.5

2 files

1.9.4

2 files

1.9.3

2 files

1.9.0

2 files

1.8.0

2 files

1.7.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

This release

1.0.0rc3 This release

2 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