Adds a test for default file init command.
This commit is contained in:
@ -14,12 +14,13 @@ def extract():
|
||||
def get_graph():
|
||||
graph = bonobo.Graph()
|
||||
graph.add_chain(
|
||||
extract,
|
||||
print,
|
||||
extract,
|
||||
print,
|
||||
)
|
||||
|
||||
return graph
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = bonobo.get_argument_parser()
|
||||
with bonobo.parse_args(parser):
|
||||
|
||||
@ -156,7 +156,7 @@ class NodeExecutionContext(WithStatistics, LoopingExecutionContext):
|
||||
|
||||
|
||||
def isflag(param):
|
||||
return isinstance(param, Token) and param in (NOT_MODIFIED,)
|
||||
return isinstance(param, Token) and param in (NOT_MODIFIED, )
|
||||
|
||||
|
||||
def split_tokens(output):
|
||||
@ -168,11 +168,11 @@ def split_tokens(output):
|
||||
"""
|
||||
if isinstance(output, Token):
|
||||
# just a flag
|
||||
return (output,), ()
|
||||
return (output, ), ()
|
||||
|
||||
if not istuple(output):
|
||||
# no flag
|
||||
return (), (output,)
|
||||
return (), (output, )
|
||||
|
||||
i = 0
|
||||
while isflag(output[i]):
|
||||
|
||||
@ -185,4 +185,4 @@ class IOBuffer():
|
||||
def memory_usage():
|
||||
import os, psutil
|
||||
process = psutil.Process(os.getpid())
|
||||
return process.memory_info()[0] / float(2 ** 20)
|
||||
return process.memory_info()[0] / float(2**20)
|
||||
|
||||
@ -34,7 +34,9 @@ class ExecutorStrategy(Strategy):
|
||||
try:
|
||||
context.tick()
|
||||
except KeyboardInterrupt:
|
||||
logging.getLogger(__name__).warning('KeyboardInterrupt received. Trying to terminate the nodes gracefully.')
|
||||
logging.getLogger(__name__).warning(
|
||||
'KeyboardInterrupt received. Trying to terminate the nodes gracefully.'
|
||||
)
|
||||
context.kill()
|
||||
break
|
||||
|
||||
@ -50,8 +52,9 @@ class ExecutorStrategy(Strategy):
|
||||
with node:
|
||||
node.loop()
|
||||
except BaseException as exc:
|
||||
logging.getLogger(__name__).info('Got {} in {} runner.'.format(get_name(exc), node),
|
||||
exc_info=sys.exc_info())
|
||||
logging.getLogger(__name__).info(
|
||||
'Got {} in {} runner.'.format(get_name(exc), node), exc_info=sys.exc_info()
|
||||
)
|
||||
|
||||
futures.append(executor.submit(_runner))
|
||||
|
||||
|
||||
@ -112,6 +112,17 @@ def test_install_requirements_for_file(runner):
|
||||
install_mock.assert_called_once_with(os.path.join(dirname, 'requirements.txt'))
|
||||
|
||||
|
||||
@all_runners
|
||||
def test_init_file(runner, tmpdir):
|
||||
target = tmpdir.join('foo.py')
|
||||
runner('init', str(target))
|
||||
assert os.path.exists(target)
|
||||
|
||||
out, err = runner('run', str(target))
|
||||
assert out.replace('\n', ' ').strip() == 'Hello World'
|
||||
assert not err
|
||||
|
||||
|
||||
@all_runners
|
||||
def test_version(runner):
|
||||
out, err = runner('version')
|
||||
|
||||
Reference in New Issue
Block a user