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.
Prepare
python3 -m venv env-plugin
source env-plugin/bin/activate
pip install pytest
pip install pytest-mock
pip install restapi_echo_server
or
pip install -r requirements.txt
Usage
Have a look at tests/test_use_cases.py 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.
Example
Some other use cases are here https://github.com/abelikt/pytest_system_test_plugin_test
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"])
call.run()
assert call.get_stdout() == "rolldice:"
assert call.returncode == 0
# Install package
install = process_factory(["sudo", "apt-get", "install", "-y", "-q", "rolldice"])
install.run()
assert install.returncode == 0
# Call and check output against a regex
call = process_factory(["rolldice", "6"])
call.run()
print(call.get_stdout())
print(call.get_stderr())
# 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"])
deinstall.run()
assert install.returncode == 0
Test
pip install .; python -m pytest -s --log-cli-level=INFO
tox
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
Links
This repo:
- https://gitlab.com/bitmuster/pytest_system_test_plugin
- https://github.com/bitmuster/pytest_system_test_plugin
Some exemplary tests:
Pytest test-framework:
PySys test-framework:
Similar plugins:
Metadata
Release files for pytest-system-test-plugin 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_system_test_plugin-0.0.2.tar.gz | 9.6 kB | Without provenance | Details for pytest_system_test_plugin-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_system_test_plugin-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for pytest_system_test_plugin-0.0.2-py3-none-any.whl |
Total release size: 17.0 kB
Release files / pytest_system_test_plugin-0.0.2.tar.gz
| Download URL | pytest_system_test_plugin-0.0.2.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aad7b713af3f87776f01d0d9e210e964d626aba2f2b14017e044afb3cbefc6ba
|
|
BLAKE2b-256 checksum How to use checksums |
0ba168db43f2744aa275d59c8b3e0550b7214ec8c8590772dddd8e0cec773278
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
|
Release files / pytest_system_test_plugin-0.0.2-py3-none-any.whl
| Download URL | pytest_system_test_plugin-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d607d91016b329a2bacb242eaaa54e534255b201902e9230a07085406a8383d5
|
|
BLAKE2b-256 checksum How to use checksums |
bda48beebb347be274129783ca5b1a15f4620dde0edb5cc1e1e21d798fdefa50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
|
Security for pytest-system-test-plugin 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.