summaryrefslogtreecommitdiff
path: root/tests/stdlib
diff options
context:
space:
mode:
authorRyan Williams <rdw@lindenlab.com>2010-02-09 08:17:46 -0800
committerRyan Williams <rdw@lindenlab.com>2010-02-09 08:17:46 -0800
commite1ee3cefbc7c1b7d2bc194374a27051fb64f6f98 (patch)
tree23bf119d4fc7ac06778b798d204a83a87aa3c1ed /tests/stdlib
parent30c7f0f677389a1dfae3d87e7e8e8b704817a022 (diff)
downloadeventlet-e1ee3cefbc7c1b7d2bc194374a27051fb64f6f98.tar.gz
Added monkeypatch stdlib tests, which test how well monkeypatching works. Unsurprisingly, some tweakage was also needed.
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/all.py47
-rw-r--r--tests/stdlib/all_modules.py41
-rw-r--r--tests/stdlib/all_monkey.py24
3 files changed, 70 insertions, 42 deletions
diff --git a/tests/stdlib/all.py b/tests/stdlib/all.py
index 33b7d8f..5236e7c 100644
--- a/tests/stdlib/all.py
+++ b/tests/stdlib/all.py
@@ -4,7 +4,7 @@ Many of these tests make connections to external servers, and all.py tries to sk
"""
-def import_main(name):
+def assimilate_patched(name):
try:
modobj = __import__(name, globals(), locals(), ['test_main'])
except ImportError:
@@ -18,44 +18,7 @@ def import_main(name):
except AttributeError:
print "No test_main for %s, assuming it tests on import" % name
-
-# quick and dirty way of testing whether we can access
-# remote hosts; any tests that try internet connections
-# will fail if we cannot
-import socket
-s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-try:
- s.settimeout(0.5)
- s.connect(('eventlet.net', 80))
- s.close()
- have_network_access = True
-except socket.error, e:
- print "Skipping network tests"
- have_network_access = False
-
-import_main('test_select')
-import_main('test_SimpleHTTPServer')
-import_main('test_asynchat')
-import_main('test_asyncore')
-import_main('test_ftplib')
-import_main('test_httplib')
-if have_network_access:
- import_main('test_httpservers')
-import_main('test_os')
-import_main('test_queue')
-if have_network_access:
- import_main('test_socket')
-import_main('test_socket_ssl')
-#import_main('test_socketserver')
-#import_main('test_subprocess')
-if have_network_access:
- import_main('test_ssl')
-import_main('test_thread')
-#import_main('test_threading')
-import_main('test_threading_local')
-if have_network_access:
- import_main('test_timeout')
-import_main('test_urllib')
-if have_network_access:
- import_main('test_urllib2')
-import_main('test_urllib2_localnet')
+import all_modules
+
+for m in all_modules.get_modules():
+ assimilate_patched(m)
diff --git a/tests/stdlib/all_modules.py b/tests/stdlib/all_modules.py
new file mode 100644
index 0000000..1a13c3c
--- /dev/null
+++ b/tests/stdlib/all_modules.py
@@ -0,0 +1,41 @@
+def get_modules():
+ test_modules = [
+ 'test_select',
+ 'test_SimpleHTTPServer',
+ 'test_asynchat',
+ 'test_asyncore',
+ 'test_ftplib',
+ 'test_httplib',
+ 'test_os',
+ 'test_queue',
+ 'test_socket_ssl',
+# 'test_socketserver',
+# 'test_subprocess',
+ 'test_thread',
+# 'test_threading',
+ 'test_threading_local',
+ 'test_urllib',
+ 'test_urllib2_localnet']
+
+ network_modules = [
+ 'test_httpservers',
+ 'test_socket',
+ 'test_ssl',
+ 'test_timeout',
+ 'test_urllib2']
+
+ # quick and dirty way of testing whether we can access
+ # remote hosts; any tests that try internet connections
+ # will fail if we cannot
+ import socket
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ try:
+ s.settimeout(0.5)
+ s.connect(('eventlet.net', 80))
+ s.close()
+ test_modules = test_modules + network_modules
+ except socket.error, e:
+ print "Skipping network tests"
+
+ return test_modules
+
diff --git a/tests/stdlib/all_monkey.py b/tests/stdlib/all_monkey.py
new file mode 100644
index 0000000..e29b09c
--- /dev/null
+++ b/tests/stdlib/all_monkey.py
@@ -0,0 +1,24 @@
+import eventlet
+eventlet.sleep(0)
+from eventlet import patcher
+patcher.monkey_patch()
+
+def assimilate_real(name):
+ print "Assimilating", name
+ try:
+ modobj = __import__('test.' + name, globals(), locals(), ['test_main'])
+ except ImportError:
+ print "Not importing %s, it doesn't exist in this installation/version of Python" % name
+ return
+ else:
+ method_name = name + "_test_main"
+ try:
+ globals()[method_name] = modobj.test_main
+ modobj.test_main.__name__ = name + '.test_main'
+ except AttributeError:
+ print "No test_main for %s, assuming it tests on import" % name
+
+import all_modules
+
+for m in all_modules.get_modules():
+ assimilate_real(m)