def test_safe_pipe_wait(self): command = pipe(['gzip'], ['zcat']) with self.assertDoesNotHang(): out, _ = command.wait() # No deadlock assert out.decode() == ''
def test_failing_pipe_command(self): with self.assertRaises(subprocess.CalledProcessError): pipe(['true'], ['false'], ['true']).wait()
def test_safe_pipe_stdout_read(self): command = pipe(['gzip'], ['zcat']) with self.assertDoesNotHang(): assert command.stdout.read().decode() == '' # No deadlock
def test_pass_subprocess_to_pipe(self): proc = pipe(['printf', 'hello'], ['gzip'], run('zcat')) assert proc.stdout.read().decode() == 'hello'
def test_environement_on_pipe(self): proc = pipe(['env'], ['egrep', '^FOO='], env={'FOO': 'BAR'}) assert proc.stdout.read().decode() == 'FOO=BAR\n'