lbpytest 0.3.0

Creator: bradpython12

Last updated:

0 purchases

TODO
Add to Cart

Description:

lbpytest 0.3.0

lbpytest

Utilities for Python-driven integration tests at LINBIT.
Installation
pip install lbpytest

Usage
ControlMaster
from lbpytest.controlmaster import SSH
from io import StringIO
import subprocess
import sys

try:
ssh = SSH("myhost.example.org")
except subprocess.CalledProcessError as e:
print(e.stderr.decode('utf-8'), file=sys.stderr)
raise e

# Run command using the hosts stdin/stdout/stderr
ssh.run("echo 'Hello, World!'")

# Save command output
output = StringIO()
ssh.run("echo 'Hello, World!'", stdout=output)
print(output.getvalue()) # prints Hello, World!

ssh.close()

Logscan
See test_logscan.py and
test_logscan_ssh.py.
Testing
The unit tests for this project can be run using pytest:
$ pytest src/lbpytest

Note that for the ControlMaster tests, a --host option is required. This should specify the IP address or hostname
of an SSH server to use for the test.
Type Checking
This library uses type annotations.
The mypy tool can be used to verify these annotations:
$ mypy src/lbpytest

License
Apache License 2.0

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.