Пример #1
0
def test_tpool_dns():
    code = '''\
from eventlet.green import socket
socket.gethostbyname('localhost')
socket.getaddrinfo('localhost', 80)
print('pass')
'''
    tests.run_python(
        path=None,
        env={'EVENTLET_TPOOL_DNS': 'yes'},
        args=['-c', code],
        expect_pass=True,
    )
Пример #2
0
def test_hub_selects():
    code = 'from eventlet import hubs\nprint(hubs.get_hub())'
    output = tests.run_python(
        path=None,
        env={'EVENTLET_HUB': 'selects'},
        args=['-c', code],
    )
    assert output.count(b'\n') == 1
    assert b'eventlet.hubs.selects.Hub' in output
Пример #3
0
 def launch_subprocess(self, filename):
     path = os.path.join(self.tempdir, filename)
     output = tests.run_python(path)
     if six.PY3:
         output = output.decode('utf-8')
         separator = '\n'
     else:
         separator = b'\n'
     lines = output.split(separator)
     return output, lines
Пример #4
0
 def launch_subprocess(self, filename):
     path = os.path.join(self.tempdir, filename)
     output = tests.run_python(path)
     if six.PY3:
         output = output.decode('utf-8')
         separator = '\n'
     else:
         separator = b'\n'
     lines = output.split(separator)
     return output, lines
Пример #5
0
 def test_monkey_patching(self):
     testcode_path = os.path.join(
         os.path.dirname(os.path.abspath(__file__)),
         'mysqldb_test_monkey_patch.py',
     )
     output = run_python(testcode_path)
     lines = output.splitlines()
     self.assertEqual(len(lines), 2, output)
     self.assertEqual(lines[0].replace("psycopg,", ""),
                      'mysqltest MySQLdb,os,select,socket,thread,time')
     self.assertEqual(lines[1], "connect True")
Пример #6
0
 def test_monkey_patching(self):
     testcode_path = os.path.join(
         os.path.dirname(os.path.abspath(__file__)),
         'mysqldb_test_monkey_patch.py',
     )
     output = run_python(testcode_path)
     lines = output.splitlines()
     self.assertEqual(len(lines), 2, output)
     self.assertEqual(lines[0].replace("psycopg,", ""),
                      'mysqltest MySQLdb,os,select,socket,thread,time')
     self.assertEqual(lines[1], "connect True")
Пример #7
0
def test_import_patched_defaults():
    code = '''\
import eventlet
eventlet.import_patched('patcher_import_patched_defaults')
'''
    isolated_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/tests/isolated'
    env = {
        'eventlet_test_import_patched_defaults': '1',
        'PYTHONPATH': os.pathsep.join(sys.path + [isolated_path]),
    }
    output = tests.run_python(path=None, env=env, args=['-c', code])
    assert output.rstrip() == b'pass', repr(output)
Пример #8
0
def test_tpool_dns():
    code = '''\
from eventlet.green import socket
socket.gethostbyname('localhost')
socket.getaddrinfo('localhost', 80)
print('pass')
'''
    output = tests.run_python(
        path=None,
        env={'EVENTLET_TPOOL_DNS': 'yes'},
        args=['-c', code],
    )
    assert output.rstrip() == b'pass'
Пример #9
0
def test_tpool_dns():
    code = '''\
from eventlet.green import socket
socket.gethostbyname('localhost')
socket.getaddrinfo('localhost', 80)
print('pass')
'''
    output = tests.run_python(
        path=None,
        env={'EVENTLET_TPOOL_DNS': 'yes'},
        args=['-c', code],
    )
    assert output.rstrip() == b'pass'
Пример #10
0
def test_subprocess_after_monkey_patch():
    code = '''\
import sys
import eventlet
eventlet.monkey_patch()
from eventlet.green import subprocess
subprocess.Popen([sys.executable, '-c', ''], stdin=subprocess.PIPE).wait()
print('pass')
'''
    output = tests.run_python(
        path=None,
        args=['-c', code],
    )
    assert output.rstrip() == b'pass'
Пример #11
0
def test_subprocess_after_monkey_patch():
    code = '''\
import sys
import eventlet
eventlet.monkey_patch()
from eventlet.green import subprocess
subprocess.Popen([sys.executable, '-c', ''], stdin=subprocess.PIPE).wait()
print('pass')
'''
    output = tests.run_python(
        path=None,
        args=['-c', code],
    )
    assert output.rstrip() == b'pass'
Пример #12
0
 def launch_subprocess(self, filename):
     path = os.path.join(self.tempdir, filename)
     output = run_python(path)
     lines = output.split("\n")
     return output, lines
Пример #13
0
 def launch_subprocess(self, filename):
     path = os.path.join(self.tempdir, filename)
     output = run_python(path)
     lines = output.split("\n")
     return output, lines
Пример #14
0
 def test_fork(self):
     output = tests.run_python('tests/hub_test_fork.py')
     lines = output.splitlines()
     self.assertEqual(lines, ["accept blocked", "child died ok"], output)
Пример #15
0
 def test_fork(self):
     output = tests.run_python('tests/hub_test_fork.py')
     lines = output.splitlines()
     self.assertEqual(lines, [b"accept blocked", b"child died ok"], output)
Пример #16
0
def test_timeouterror_deprecated():
    # https://github.com/eventlet/eventlet/issues/378
    code = '''import eventlet; eventlet.Timeout(1).cancel(); print('pass')'''
    args = ['-Werror:eventlet.Timeout:DeprecationWarning', '-c', code]
    tests.run_python(path=None, args=args, expect_pass=True)