Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
eb4bcd5a
Commit
eb4bcd5a
authored
May 02, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test__subprocess.py
parent
91391323
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
greentest/test__subprocess.py
greentest/test__subprocess.py
+47
-0
No files found.
greentest/test__subprocess.py
0 → 100644
View file @
eb4bcd5a
import
sys
import
os
import
greentest
import
time
from
gevent
import
subprocess
,
sleep
class
Test
(
greentest
.
TestCase
):
def
test_exit
(
self
):
popen
=
subprocess
.
Popen
([
sys
.
executable
,
'-c'
,
'import sys; sys.exit(10)'
])
self
.
assertEqual
(
popen
.
wait
(),
10
)
def
test_child_exception
(
self
):
try
:
subprocess
.
Popen
([
'*'
]).
wait
()
except
OSError
,
ex
:
assert
ex
.
errno
==
2
,
ex
else
:
raise
AssertionError
(
'Expected OSError: [Errno 2] No such file or directory'
)
if
os
.
path
.
exists
(
'/proc'
):
def
test_leak
(
self
):
fd_directory
=
'/proc/%d/fd'
%
os
.
getpid
()
num_before
=
len
(
os
.
listdir
(
fd_directory
))
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"print()"
],
stdout
=
subprocess
.
PIPE
)
p
.
wait
()
del
p
num_after
=
len
(
os
.
listdir
(
fd_directory
))
self
.
assertEqual
(
num_before
,
num_after
)
def
test_communicate
(
self
):
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'import sys,os;'
'sys.stderr.write("pineapple");'
'sys.stdout.write(sys.stdin.read())'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
(
stdout
,
stderr
)
=
p
.
communicate
(
"banana"
)
self
.
assertEqual
(
stdout
,
"banana"
)
self
.
assertEqual
(
stderr
,
"pineapple"
)
if
__name__
==
'__main__'
:
greentest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment