File tree 1 file changed +35
-0
lines changed
Filter options
1 file changed +35
-0
lines changed
Original file line number Diff line number Diff line change @@ -27,8 +27,43 @@ def sleep(secs):
27
27
assert p .poll () == 0
28
28
assert p .returncode == 0
29
29
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
+
30
41
p = subprocess .Popen (echo ("test" ), stdout = subprocess .PIPE )
31
42
p .wait ()
32
43
33
44
34
45
assert 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