Skip to main content

Pyst - Pytest System-Test Plugin

Project description

Pyst - Pytest System-Test Plugin

Note: This plugin is the state experimental / techdemo !

This plugin should ease system-testing with Pytest. To achieve this it provides a simple interface to manage processes in the operating system like starting them, running background processes and evaluating the output.

This is especially useful to prepare the system for a test (e.g. start background prcesses, databases, servers, ...) and then run the programm under test in a blackbox-manner.

Features should be (intended, partly unfinished):

  • DONE: Starting, stopping and managing processes in the OS
  • DONE: Pysys like interface to run systemtests
    • Especially startProcess and assertGrep
  • DONE: Logs all outputs to files and can later on run assertions on that outputs
  • Should work:
    • DONE: Start and stop processes with and without sudo
    • Prepare configuration files for executables
  • DONE: Simple user fixtures
  • Provides envioronment fixtures / group fixtures / environments (terminology depends on the framework you are used to).
  • Multistage environments fixtures
    • Supports you to write your own fixures

So far, this will only un on unix-like systems.


python3 -m venv env-plugin
source env-plugin/bin/activate
pip install pytest
pip install pytest-mock
pip install restapi_echo_server
pip install -r requirements.txt


Have a look at tests/ it contains some exemplary use-cases. We use an echo-server and curl to be near to real use cases. More will be added soon.


Some other use cases are here

import re
import pytest

def test_use_rolldice(process_factory):
    """This test installs a package via the package management, uses
    it and removes it again.

    # make sure it is not installed
    call = process_factory(["whereis", "rolldice"])
    assert call.get_stdout() == "rolldice:"
    assert call.returncode == 0

    # Install package
    install = process_factory(["sudo", "apt-get", "install", "-y", "-q", "rolldice"])
    assert install.returncode == 0

    # Call and check output against a regex
    call = process_factory(["rolldice", "6"])

    # match a single digit
    assert re.match(r"^\d$", call.get_stdout()) is not None
    assert call.returncode == 0

    # deinstall it
    deinstall = process_factory(["sudo", "apt-get", "remove", "-y", "-q", "rolldice"])
    assert install.returncode == 0


pip install .; python -m pytest -s --log-cli-level=INFO
tox -e {lint, linttest}

Measure test execution

pip install .; python -m pytest -s --log-cli-level=INFO --junitxml=junit.xml
xmllint junit.xml --format > junitf.xml


This repo:

Some exemplary tests:

Pytest test-framework:

PySys test-framework:

Similar plugins:

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

pytest_system_test_plugin-0.0.2.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

Supported by

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