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
a297a4d2
Commit
a297a4d2
authored
Jul 26, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restore test_patched_threading.py; update helper.py
parent
ff21e5ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
19 deletions
+42
-19
greentest/helper.py
greentest/helper.py
+22
-18
greentest/test_patched_threading.py
greentest/test_patched_threading.py
+20
-1
No files found.
greentest/helper.py
View file @
a297a4d2
...
...
@@ -5,6 +5,12 @@ import tempfile
import
glob
from
pipes
import
quote
chdir
=
os
.
path
.
join
(
tempfile
.
gettempdir
(),
'gevent-test'
)
try
:
os
.
makedirs
(
chdir
)
except
EnvironmentError
:
pass
version
=
'%s.%s'
%
sys
.
version_info
[:
2
]
missing_modules
=
{
...
...
@@ -46,7 +52,7 @@ def imp_find_dotted_module(name):
return
result
def
_prepare_stdlib_test
(
filenam
e
):
def
prepare_stdlib_test
(
filename
,
assets
=
Non
e
):
patch_all
(
timeout
=
20
)
import
test
try
:
...
...
@@ -77,27 +83,25 @@ def _prepare_stdlib_test(filename):
module_code
=
compile
(
module_source
,
_filename
,
'exec'
)
print
>>
sys
.
stderr
,
'Testing %s with monkey patching'
%
_filename
return
module_code
,
_filename
def
prepare_stdlib_test
(
filename
):
return
_prepare_stdlib_test
(
filename
)[
0
]
copy_assets
(
os
.
path
.
dirname
(
_filename
),
assets
)
os
.
chdir
(
chdir
)
return
module_code
def
run
(
filename
,
d
,
assets
=
None
):
module_code
,
filename
=
_prepare_stdlib_test
(
filename
)
chdir
=
os
.
path
.
join
(
tempfile
.
gettempdir
(),
'gevent-test'
)
try
:
os
.
makedirs
(
chdir
)
except
EnvironmentError
:
pass
def
copy_assets
(
source
,
assets
):
if
assets
:
directory
=
os
.
path
.
dirname
(
filename
)
cwd
=
os
.
getcwd
()
os
.
chdir
(
directory
)
if
isinstance
(
assets
,
basestring
):
assets
=
glob
.
glob
(
assets
)
for
asset
in
assets
:
os
.
system
(
'cp -r %s %s'
%
(
quote
(
asset
),
quote
(
os
.
path
.
join
(
chdir
,
asset
))))
try
:
if
isinstance
(
assets
,
basestring
):
assets
=
glob
.
glob
(
assets
)
for
asset
in
assets
:
os
.
system
(
'cp -r %s %s'
%
(
quote
(
asset
),
quote
(
os
.
path
.
join
(
chdir
,
asset
))))
finally
:
os
.
chdir
(
cwd
)
os
.
chdir
(
chdir
)
exec
module_code
in
d
def
run
(
filename
,
d
,
assets
=
None
):
exec
prepare_stdlib_test
(
filename
)
in
d
greentest/test_patched_threading.py
View file @
a297a4d2
import
helper
helper
.
run
(
__file__
,
globals
())
module
=
helper
.
prepare_stdlib_test
(
__file__
)
import
sys
import
subprocess
from
subprocess
import
Popen
as
_Popen
monkey_patch
=
'from gevent import monkey; monkey.patch_all()
\
n
\
n
'
class
MyPopen
(
_Popen
):
def
__init__
(
self
,
arg
,
*
args
,
**
kwargs
):
if
arg
[:
2
]
==
[
sys
.
executable
,
'-c'
]:
assert
len
(
arg
)
==
3
,
arg
arg
=
arg
[:
2
]
+
[
monkey_patch
+
arg
[
2
]]
_Popen
.
__init__
(
self
,
arg
,
*
args
,
**
kwargs
)
subprocess
.
Popen
=
MyPopen
exec
module
in
globals
()
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