def test_iteration_error_stderr(): p = Sh('cat', 'DOES-NOT-EXIST') try: p.next() assert False and 'Expected ShError' except ShError, e: assert 'cat: DOES-NOT-EXIST: No such file or directory\n' == e.stderr
def test_iteration_error_stdout_no_stderr(): p = Sh('bash', '-c', 'echo hello ; false') assert 'hello' == p.next() try: p.next() assert False and 'Expected ShError' except ShError, e: pass
def test_iteration_no_newline_no_error(): x = Sh('printf', 'hello') assert 'hello' == x.next() try: x.next() assert False and 'Expected StopIteration' except StopIteration: pass
def test_iteration_error_no_stderr(): p = Sh('false') try: p.next() assert False and 'Expected ShError' except ShError, e: assert 1 == e.returncode assert ('false',) == e.cmd assert '' == e.stderr
def test_iteration_many_lines_no_error(): x = Sh('bash', '-c', 'for i in {1..1000}; do echo hello; done') for i in xrange(1000): assert 'hello' == x.next() try: x.next() assert False and 'Expected StopIteration' except StopIteration: pass