Adds a test for default file init command.
This commit is contained in:
@ -14,12 +14,13 @@ def extract():
|
|||||||
def get_graph():
|
def get_graph():
|
||||||
graph = bonobo.Graph()
|
graph = bonobo.Graph()
|
||||||
graph.add_chain(
|
graph.add_chain(
|
||||||
extract,
|
extract,
|
||||||
print,
|
print,
|
||||||
)
|
)
|
||||||
|
|
||||||
return graph
|
return graph
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = bonobo.get_argument_parser()
|
parser = bonobo.get_argument_parser()
|
||||||
with bonobo.parse_args(parser):
|
with bonobo.parse_args(parser):
|
||||||
|
|||||||
@ -156,7 +156,7 @@ class NodeExecutionContext(WithStatistics, LoopingExecutionContext):
|
|||||||
|
|
||||||
|
|
||||||
def isflag(param):
|
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):
|
def split_tokens(output):
|
||||||
@ -168,11 +168,11 @@ def split_tokens(output):
|
|||||||
"""
|
"""
|
||||||
if isinstance(output, Token):
|
if isinstance(output, Token):
|
||||||
# just a flag
|
# just a flag
|
||||||
return (output,), ()
|
return (output, ), ()
|
||||||
|
|
||||||
if not istuple(output):
|
if not istuple(output):
|
||||||
# no flag
|
# no flag
|
||||||
return (), (output,)
|
return (), (output, )
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while isflag(output[i]):
|
while isflag(output[i]):
|
||||||
|
|||||||
@ -185,4 +185,4 @@ class IOBuffer():
|
|||||||
def memory_usage():
|
def memory_usage():
|
||||||
import os, psutil
|
import os, psutil
|
||||||
process = psutil.Process(os.getpid())
|
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:
|
try:
|
||||||
context.tick()
|
context.tick()
|
||||||
except KeyboardInterrupt:
|
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()
|
context.kill()
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -50,8 +52,9 @@ class ExecutorStrategy(Strategy):
|
|||||||
with node:
|
with node:
|
||||||
node.loop()
|
node.loop()
|
||||||
except BaseException as exc:
|
except BaseException as exc:
|
||||||
logging.getLogger(__name__).info('Got {} in {} runner.'.format(get_name(exc), node),
|
logging.getLogger(__name__).info(
|
||||||
exc_info=sys.exc_info())
|
'Got {} in {} runner.'.format(get_name(exc), node), exc_info=sys.exc_info()
|
||||||
|
)
|
||||||
|
|
||||||
futures.append(executor.submit(_runner))
|
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'))
|
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
|
@all_runners
|
||||||
def test_version(runner):
|
def test_version(runner):
|
||||||
out, err = runner('version')
|
out, err = runner('version')
|
||||||
|
|||||||
Reference in New Issue
Block a user