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, )
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
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
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")
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)
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'
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'
def launch_subprocess(self, filename): path = os.path.join(self.tempdir, filename) output = run_python(path) lines = output.split("\n") return output, lines
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)
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)
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)