Commit f483df54 authored by Denis Bilenko's avatar Denis Bilenko

update test_patched_xxx.py to chdir to /tmp/ and copy necessary assets there (like .pem files)

parent f30e5294
import sys import sys
import os import os
import imp import imp
import tempfile
import glob
from pipes import quote
version = '%s.%s' % sys.version_info[:2] version = '%s.%s' % sys.version_info[:2]
...@@ -81,6 +84,20 @@ def prepare_stdlib_test(filename): ...@@ -81,6 +84,20 @@ def prepare_stdlib_test(filename):
return _prepare_stdlib_test(filename)[0] return _prepare_stdlib_test(filename)[0]
def run(filename, globals): def run(filename, d, assets=None):
module_code, filename = _prepare_stdlib_test(filename) module_code, filename = _prepare_stdlib_test(filename)
exec module_code in globals chdir = os.path.join(tempfile.gettempdir(), 'gevent-test')
try:
os.makedirs(chdir)
except EnvironmentError:
pass
if assets:
directory = os.path.dirname(filename)
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))))
os.chdir(chdir)
exec module_code in d
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals(), '*.pem')
import os
import glob
import helper import helper
before = set(glob.glob('@test_*_tmp'))
helper.run(__file__, globals()) helper.run(__file__, globals())
for filename in set(glob.glob('@test_*_tmp')) - before:
os.unlink(filename)
import subprocess
assert 'gevent' in repr(subprocess.Popen.__init__.im_func.func_code), repr(subprocess.Popen.__init__.im_func.func_code)
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper 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()
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
import helper import helper
exec helper.prepare_stdlib_test(__file__) in globals() helper.run(__file__, globals())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment