def test_nonblock_removed(self): # see issue #134 r, w = os.pipe() p = subprocess.Popen(['grep', 'text'], stdin=subprocess.FileObject(r)) try: os.close(w) time.sleep(0.1) self.assertEqual(p.poll(), None) finally: if p.poll() is None: p.kill()
def test_nonblock_removed(self): # see issue #134 r, w = os.pipe() p = subprocess.Popen(['grep', 'text'], stdin=subprocess.FileObject(r)) try: # Closing one half of the pipe causes Python 3 on OS X to terminate the # child process; it exits with code 1 and the assert that p.poll is None # fails. Removing the close lets it pass under both Python 3 and 2.7. # If subprocess.Popen._remove_nonblock_flag is changed to a noop, then # the test fails (as expected) even with the close removed #os.close(w) time.sleep(0.1) self.assertEqual(p.poll(), None) finally: if p.poll() is None: p.kill()
def test_nonblock_removed(self): import subprocess as orig_subprocess r, w = os.pipe() p = orig_subprocess.Popen(['grep', 'text'], stdin=r) try: os.close(w) time.sleep(0.1) expected = p.poll() finally: if p.poll() is None: p.kill() # see issue #134 r, w = os.pipe() p = subprocess.Popen(['grep', 'text'], stdin=subprocess.FileObject(r)) try: os.close(w) time.sleep(0.1) self.assertEqual(p.poll(), expected) finally: if p.poll() is None: p.kill()