[qa] covers __main__

This commit is contained in:
Romain Dorgueil
2017-05-22 19:57:08 +02:00
parent 56f9c334f6
commit a50b21e46d
3 changed files with 53 additions and 34 deletions

View File

@ -1,10 +1,21 @@
import pkg_resources
import pytest
from bonobo import get_examples_path, __version__
from bonobo import __version__, get_examples_path
from bonobo.commands import entrypoint
def runner_entrypoint(*args):
return entrypoint(list(args))
def runner_module(*args):
return entrypoint(list(args))
all_runners = pytest.mark.parametrize('runner', [runner_entrypoint, runner_module])
def test_entrypoint():
commands = {}
@ -13,31 +24,31 @@ def test_entrypoint():
assert 'init' in commands
assert 'run' in commands
assert 'version' in commands
def test_no_command(capsys):
@all_runners
def test_no_command(runner, capsys):
with pytest.raises(SystemExit):
entrypoint([])
runner()
_, err = capsys.readouterr()
assert 'error: the following arguments are required: command' in err
def test_init():
pass # need ext dir
def test_run(capsys):
entrypoint(['run', '--quiet', get_examples_path('types/strings.py')])
@all_runners
def test_run(runner, capsys):
runner('run', '--quiet', get_examples_path('types/strings.py'))
out, err = capsys.readouterr()
out = out.split('\n')
assert out[0].startswith('Foo ')
assert out[1].startswith('Bar ')
assert out[2].startswith('Baz ')
def test_version(capsys):
entrypoint(['version'])
@all_runners
def test_version(runner, capsys):
runner('version')
out, err = capsys.readouterr()
out = out.strip()
assert out.startswith('bonobo ')
assert out.endswith(__version__)