File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,43 @@ def sleep(secs):
2727assert p .poll () == 0
2828assert p .returncode == 0
2929
30+ p = subprocess .Popen (sleep (2 ))
31+
32+ assert p .poll () is None
33+
34+ with assert_raises (subprocess .TimeoutExpired ):
35+ assert p .wait (1 )
36+
37+ p .wait ()
38+
39+ assert p .returncode == 0
40+
3041p = subprocess .Popen (echo ("test" ), stdout = subprocess .PIPE )
3142p .wait ()
3243
3344
3445assert p .stdout .read ().strip () == b"test"
46+
47+ p = subprocess .Popen (sleep (2 ))
48+ p .terminate ()
49+ p .wait ()
50+ if is_unix :
51+ assert p .returncode == - signal .SIGTERM
52+ else :
53+ assert p .returncode == 1
54+
55+ p = subprocess .Popen (sleep (2 ))
56+ p .kill ()
57+ p .wait ()
58+ if is_unix :
59+ assert p .returncode == - signal .SIGKILL
60+ else :
61+ assert p .returncode == 1
62+
63+ p = subprocess .Popen (echo ("test" ), stdout = subprocess .PIPE )
64+ (stdout , stderr ) = p .communicate ()
65+ assert stdout .strip () == b"test"
66+
67+ p = subprocess .Popen (sleep (5 ), stdout = subprocess .PIPE )
68+ with assert_raises (subprocess .TimeoutExpired ):
69+ p .communicate (timeout = 1 )
You can’t perform that action at this time.
0 commit comments