Added all.py convenience module for running stdlib tests. Patcherized test_timeout.
This commit is contained in:
@@ -39,14 +39,14 @@ Standard Library Tests
|
||||
|
||||
Eventlet provides for the ability to test itself with the standard Python networking tests. This verifies that the libraries it wraps work at least as well as the standard ones do. The directory tests/stdlib contains a bunch of stubs that import the standard lib tests from your system and run them. If you do not have any tests in your python distribution, they'll simply fail to import.
|
||||
|
||||
Run the standard library tests with nose; simply do:
|
||||
There's a convenience module called all.py designed to handle the impedance mismatch between Nose and the standard tests:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
$ cd tests/
|
||||
$ nosetests stdlib
|
||||
$ nosetests tests/stdlib/all.py
|
||||
|
||||
That will run all the tests, though the output will be a little weird because it will look like Nose is running about 20 tests, each of which consists of a bunch of sub-tests. Not all test modules are present in all versions of Python, so there will be an occasional printout of "Not importing %s, it doesn't exist in this installation/version of Python".
|
||||
|
||||
That should get you started. At this time this generates a bunch of spurious failures, due to `Nose issue 162 <http://code.google.com/p/python-nose/issues/detail?id=162>`_, which incorrectly identifies helper methods as test cases. Therefore, ignore any failure for the reason ``TypeError: foo() takes exactly N arguments (2 given)``, and sit tight until a version of Nose is released that fixes the issue.
|
||||
|
||||
Testing Eventlet Hubs
|
||||
---------------------
|
||||
|
38
tests/stdlib/all.py
Normal file
38
tests/stdlib/all.py
Normal file
@@ -0,0 +1,38 @@
|
||||
""" Convenience module for running standard library tests with nose. The standard tests are not especially homogeneous, but they mostly expose a test_main method that does the work of selecting which tests to run based on what is supported by the platform. On its own, Nose would run all possible tests and many would fail; therefore we collect all of the test_main methods here in one module and Nose can run it. Hopefully in the future the standard tests get rewritten to be more self-contained.
|
||||
|
||||
Many of these tests make connections to external servers, causing failures when run while disconnected from the internet.
|
||||
"""
|
||||
|
||||
|
||||
def import_main(g, name):
|
||||
try:
|
||||
modobj = __import__(name, g, fromlist=['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:
|
||||
g[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_main(globals(), 'test_SimpleHTTPServer')
|
||||
import_main(globals(), 'test_asynchat')
|
||||
import_main(globals(), 'test_asyncore')
|
||||
import_main(globals(), 'test_ftplib')
|
||||
import_main(globals(), 'test_httplib')
|
||||
#import_main(globals(), 'test_httpservers')
|
||||
import_main(globals(), 'test_select')
|
||||
import_main(globals(), 'test_socket')
|
||||
#import_main(globals(), 'test_socket_ssl')
|
||||
import_main(globals(), 'test_socketserver')
|
||||
#import_main(globals(), 'test_ssl')
|
||||
import_main(globals(), 'test_thread')
|
||||
#import_main(globals(), 'test_threading')
|
||||
#import_main(globals(), 'test_threading_local')
|
||||
import_main(globals(), 'test_timeout')
|
||||
import_main(globals(), 'test_urllib')
|
||||
#import_main(globals(), 'test_urllib2')
|
||||
#import_main(globals(), 'test_urllib2_localnet')
|
@@ -1,15 +1,15 @@
|
||||
from eventlet import patcher
|
||||
from eventlet.green import socket
|
||||
from eventlet.green import time
|
||||
|
||||
from test import test_timeout
|
||||
|
||||
test_timeout.socket = socket
|
||||
test_timeout.time = time
|
||||
patcher.inject('test.test_timeout',
|
||||
globals(),
|
||||
('socket', socket),
|
||||
('time', time))
|
||||
|
||||
# to get past the silly 'requires' check
|
||||
test_timeout.__name__ = '__main__'
|
||||
|
||||
from test.test_timeout import *
|
||||
from test import test_support
|
||||
test_support.use_resources = ['network']
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
Reference in New Issue
Block a user