mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
30 lines
473 B
Python
30 lines
473 B
Python
import subprocess
|
|
import time
|
|
|
|
from testutils import assertRaises
|
|
|
|
p = subprocess.Popen(["echo", "test"])
|
|
|
|
time.sleep(0.1)
|
|
|
|
assert p.returncode is None
|
|
|
|
assert p.poll() == 0
|
|
assert p.returncode == 0
|
|
|
|
p = subprocess.Popen(["sleep", "2"])
|
|
|
|
assert p.poll() is None
|
|
|
|
with assertRaises(subprocess.TimeoutExpired):
|
|
assert p.wait(1)
|
|
|
|
p.wait()
|
|
|
|
assert p.returncode == 0
|
|
|
|
p = subprocess.Popen(["echo", "test"], stdout=subprocess.PIPE)
|
|
p.wait()
|
|
|
|
assert p.stdout.read() == b"test\n"
|