bddcli
Test any command line interface in BDD manner.
About
A framework to easily test your command line interface in another(isolated)
process and gather stdout, stderr and exit-status of the process.
Thanks to https://github.com/cheremnov for the Windows support.
Installation
Only Python >= 3.6 is supported.
pip install bddcli
Quickstart
Arguments
import sys
from bddcli import Given, when, stdout, status, stderr, Application, given
def foo():
print(' '.join(sys.argv))
return 0
app = Application('foo', 'mymodule:foo')
with Given(app, 'bar'):
assert status == 0
assert stdout == 'foo bar\n'
# Without any argument
when(given - 'bar')
assert stdout == 'foo\n'
# Pass multiple arguments
when('bar baz')
assert stdout == 'foo bar baz\n'
# Pass multiple arguments, another method
when(['bar', 'baz'])
assert stdout == 'foo bar baz\n'
# Add an argument
when(given + 'baz')
assert stdout == 'foo bar baz\n'
Standard input
with Given(app, stdin='foo'):
assert ...
# stdin is empty
when(stdin='')
assert ...
Standard output and error
from bddcli import stderr, stdout
assert stderr == ...
assert stdout == ...
Environment variables
import os
from bddcli import Given, stdout, Application, when, given
def foo():
e = os.environ.copy()
del e['PWD']
print(' '.join(f'{k}: {v}' for k, v in e.items()))
app = Application('foo', 'mymodule:foo')
with Given(app, environ={'bar': 'baz'}):
assert stdout == 'bar: baz\n'
# Without any variable
when(environ=given - 'bar')
assert stdout == '\n'
# Add another variables
when(environ=given + {'qux': 'quux'})
assert stdout == 'bar: baz qux: quux\n'
See tests for more examples.
Metadata
Release files for bddcli 2.10.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bddcli-2.10.3.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bddcli-2.10.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.1 kB
Release files / bddcli-2.10.3.tar.gz
| Download URL | bddcli-2.10.3.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8587e2a988a85722a6758c492ae30dd1de52fa4f3acfa00a452d7610d96387c2
|
|
BLAKE2b-256 checksum How to use checksums |
a90ddb7fbb0f54761e336d49e8a49cd6417ce2d4574fc9e9a1f26da202cd215c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / bddcli-2.10.3-py3-none-any.whl
| Download URL | bddcli-2.10.3-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80771b8af75ecc8ddc7a7573ab796d810b70480e81cbeb3655507789eab626da
|
|
BLAKE2b-256 checksum How to use checksums |
2099879c89bf3909a664cd27461266b539cbc57b0e08adec3ddf8c29354dc3de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|