예제 #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')
예제 #2
0
파일: command.py 프로젝트: BAM-X/wharfrat
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)
예제 #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())
예제 #4
0
    def test_issue_command_print_result(self):

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

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

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

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