Esempio n. 1
0
    def test_raises_on_err(self):
        with self.assertRaises(CalledProcessError) as e:

            command = 'echo "FAIL"; exit 1'
            interface.issue(command)

        self.assertEqual(e.exception.returncode, 1)
        self.assertEqual(e.exception.output, 'FAIL\n')
Esempio n. 2
0
def main(args=None):

    parser = create_parser()
    _args = parser.parse_args(args)
    translater = WharfRat.build(_args)
    command = get_command(_args)
    result = command(translater, _args.task)
    for item in result:
        issue(item)
Esempio n. 3
0
    def test_streaming(self, mock_stdout):

        # NOTE: doesn't test the timing; for that we'd need separate threads/processes
        command = 'echo a; sleep 0; echo b >&2; exit 0'
        output = interface.issue(command)

        self.assertEqual(output, 'a\nb\n')
        self.assertEqual(output, mock_stdout.getvalue())
Esempio n. 4
0
    def test_issue_command_print_result(self):

        command = 'echo hello'
        output = interface.issue(command)

        self.assertEqual(output, 'hello\n')
Esempio n. 5
0
    def test_print_stderr(self):

        command = 'echo "error" >&2'
        output = interface.issue(command)

        self.assertEqual(output, 'error\n')