diff --git a/eventlet/patcher.py b/eventlet/patcher.py index 4b33ae6..1383d87 100644 --- a/eventlet/patcher.py +++ b/eventlet/patcher.py @@ -81,6 +81,15 @@ def import_patched(module_name, *additional_modules, **kw_additional_modules): def patch_function(func, *additional_modules): """Huge hack here -- patches the specified modules for the duration of the function call.""" + if not additional_modules: + # supply some defaults + additional_modules = ( + _green_os_modules() + + _green_select_modules() + + _green_socket_modules() + + _green_thread_modules() + + _green_time_modules()) + def patched(*args, **kw): saved = {} for name, mod in additional_modules: diff --git a/tests/stdlib/test_socket_ssl.py b/tests/stdlib/test_socket_ssl.py index d418e1a..72a1d7b 100644 --- a/tests/stdlib/test_socket_ssl.py +++ b/tests/stdlib/test_socket_ssl.py @@ -2,8 +2,6 @@ from eventlet import patcher from eventlet.green import socket -from eventlet.green import urllib -from eventlet.green import threading # enable network resource import test.test_support @@ -21,16 +19,10 @@ try: except AttributeError: raise ImportError("Socket module doesn't support ssl") -patcher.inject('test.test_socket_ssl', - globals(), - ('socket', socket), - ('urllib', urllib), - ('threading', threading)) +patcher.inject('test.test_socket_ssl', globals()) -test_basic = patcher.patch_function(test_basic, - ('urllib', urllib)) -test_rude_shutdown = patcher.patch_function(test_rude_shutdown, - ('threading', threading)) +test_basic = patcher.patch_function(test_basic) +test_rude_shutdown = patcher.patch_function(test_rude_shutdown) def test_main(): if not hasattr(socket, "ssl"):