Exemplo n.º 1
0
    def test_go_not_sure_on_exit(self, printing, mocker, instances):
        mock_input = mocker.patch('__builtin__.raw_input')
        mock_input.side_effect = ['', 'N', '', 'Y', '']
        subject.COMMANDS = {
            'init': mocker.Mock(autospec=True),
            'info': mocker.Mock(autospec=True),
            'test': mocker.Mock(autospec=True)
        }

        subject.go()

        subject.COMMANDS['init'].display.assert_called_with()
        subject.COMMANDS['info'].display.assert_called_with()
        subject.COMMANDS['init'].run.assert_called_with()
        subject.COMMANDS['info'].run.assert_called_with()
        assert self.mock_print.mock_calls == [
            mocker.call('available commands:'),
            mocker.call('only one per line, all lower case'),
            mocker.call('blank line to exit\n'),
            mocker.call(''),
            mocker.call(
                "commands: ['info', 'test', 'init'], (blank line to exit)"),
            mocker.call('')
        ]

        assert mock_input.mock_calls == [
            mocker.call(),
            mocker.call(
                'It looks like there are instances still running. Are you sure you want to exit? [y/N] '
            ),
            mocker.call(),
            mocker.call(
                'It looks like there are instances still running. Are you sure you want to exit? [y/N] '
            )
        ]
Exemplo n.º 2
0
    def test_go_without_instances(self, printing, mocker):
        mock_input = mocker.patch('__builtin__.raw_input')
        mock_input.side_effect = ['']
        subject.COMMANDS = {
            'init': mocker.Mock(autospec=True),
            'info': mocker.Mock(autospec=True)
        }

        subject.go()

        assert self.mock_print.mock_calls == [
            mocker.call(
                "You haven't configured any nodes for this run of TNT. Exiting..."
            )
        ]
Exemplo n.º 3
0
#!/usr/bin/env python2
# Copyright (c) 2019, Substratum LLC (https://substratum.net) and/or its affiliates. All rights reserved.
from runner import go

if __name__ == '__main__':
    print 'Hello!'
    go()
    print "Goodbye!"
Exemplo n.º 4
0
from lexer import lexems, SyntaxError
try:
    L = list(lexems(code.split('\n')))
except SyntaxError:
    log.error("Syntax error, terminating interpretation... See details above")
    exit(1)
except:
    log.error("Something strange happened :-(")
    raise

from syntaxer import buildTree, SyntaxError
try:
    T = buildTree(L)
except SyntaxError:
    log.error("Syntax error, terminating interpretation... See details above.")
    exit(1)
except:
    log.error("Something strange :-(")
    raise

from runner import go, InterpretationError

try:
    go(T)
except InterpretationError:
    log.error("Interpretation error, terminating interpretation... See details above")
except:
    log.error("Something strange :-(")
    raise