Generate test cases for shell scripts
Project description
PyShellTest
Generate python test cases for shell commands based on simple configuration. Allows you to seemlessly test commands that need to be run from a shell but within the python testing framework.
We all need to write more tests and including outside commands allows for more coverage. For instance:
- Add linkchecker to your integ runs for a django project
- Ensure tools in
bin/
have a--help
Installation
TODO
Integration
Add this to you test files where you see fit:
generator = PyShellTestGenerator.from_json("sample-config.json")
test_class = generator.generate()
You can then run your tests like you would normally and PyShellTest will generate tests based on your conifg.json
python -m pytest tests/
Configuration
See sample-config.json
as well as tests/test-config.json
Example configuration for a command:
{
"the-command-name": {
# The command to run
"command": ["path/to/script.sh"],
# How long to wait before timing out
"timeout": 30,
# Print the output of the ocmmand to stdout
"print_output": true,
# Expect this in stdout, fail otherwise
"stdout_contains": "bar"
# Expect this in stderr, fail otherwise
"stderr_contains": "bar"
# Set this dict if you expect errors from the command
"error": {
# Expect an error
"expect": true,
# Expect an error with this class
"error_class": "FileNotFoundError"
},
}
}
Development
Testing
How to test this project
poetry run python -m pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyshelltest-0.6-11dev0.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for pyshelltest-0.6_11dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbc6ca963cacfb65c2ddc30a59c7e326cde18207b823603eb8179b940d496a68 |
|
MD5 | 2e8f0651115c8124e461a53cfb775a89 |
|
BLAKE2b-256 | 65e2e833769426588fc1a03f04286d325440e327dcedcf4aa1fd9cad453baf54 |