s0undt3ch / pytest-shell-utilities

Simple pytest(pytest.org) plugin which provides fixtures and code to help with running shell commands on tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

And, that's honestly it.

Usage

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

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.

Additionally, the return object's .stdout and .stderr can be line matched using pytest.pytester.LineMatcher:

Documentation

The full documentation can be seen here.

About

Simple pytest(pytest.org) plugin which provides fixtures and code to help with running shell commands on tests

License:Apache License 2.0


Languages

Language:Python 100.0%