Commit e614a824 authored by Jason Madden's avatar Jason Madden

Split the remaining example tests into their own files.

parent a9b61d6c
...@@ -522,11 +522,9 @@ def main(): ...@@ -522,11 +522,9 @@ def main():
options = parser.parse_args() options = parser.parse_args()
# options.use will be either None for not given, or a list # options.use will be either None for not given, or a list
# of the last specified -u argument. # of the last specified -u argument.
if options.use is None: # If not given, use the default, which we'll take from the environment, if set.
# The default, which we'll take from the environment, if set. options.use = list(set(parse_resources() if options.use is None else options.use))
options.use = parse_resources()
options.use = list(set(options.use))
# Whether or not it came from the environment, put it in the # Whether or not it came from the environment, put it in the
# environment now. # environment now.
os.environ['GEVENTTEST_USE_RESOURCES'] = unparse_resources(options.use) os.environ['GEVENTTEST_USE_RESOURCES'] = unparse_resources(options.use)
......
...@@ -39,9 +39,6 @@ if sys.platform == 'win32': ...@@ -39,9 +39,6 @@ if sys.platform == 'win32':
# other Windows-related issues (need investigating) # other Windows-related issues (need investigating)
FAILING_TESTS += [ FAILING_TESTS += [
'FLAKY test__greenletset.py', 'FLAKY test__greenletset.py',
# This has been seen to fail on Py3 and Py2 due to socket reuse
# errors, probably timing related again.
'FLAKY test___example_servers.py',
] ]
if APPVEYOR: if APPVEYOR:
...@@ -344,9 +341,14 @@ TEST_FILE_OPTIONS = { ...@@ -344,9 +341,14 @@ TEST_FILE_OPTIONS = {
# tests that don't do well when run on busy box # tests that don't do well when run on busy box
# or that are mutually exclusive
RUN_ALONE = [ RUN_ALONE = [
'test__threadpool.py', 'test__threadpool.py',
'test__examples.py', # These share the same port, which means they can conflict
# between concurrent test runs too
# XXX: Fix this by dynamically picking a port.
'test__example_wsgiserver.py',
'test__example_webproxy.py',
] ]
......
from __future__ import print_function, absolute_import from __future__ import print_function, absolute_import
from gevent import monkey; monkey.patch_all(subprocess=True) from gevent import monkey; monkey.patch_all(subprocess=True)
import signal import signal
import sys
import socket import socket
from time import sleep from time import sleep
......
from unittest import SkipTest
import gevent.testing as greentest
from . import test__example_wsgiserver
@greentest.skipOnCI("Timing issues sometimes lead to a connection refused")
@greentest.skipWithoutExternalNetwork("Tries to reach google.com")
class Test_webproxy(test__example_wsgiserver.Test_wsgiserver):
server = 'webproxy.py'
def _run_all_tests(self):
status, data = self.read('/')
self.assertEqual(status, '200 OK')
self.assertIn(b"gevent example", data)
status, data = self.read('/http://www.google.com')
self.assertEqual(status, '200 OK')
self.assertIn(b'google', data.lower())
def test_a_blocking_client(self):
# Not applicable
raise SkipTest("Not applicable")
if __name__ == '__main__':
greentest.main()
...@@ -4,7 +4,7 @@ try: ...@@ -4,7 +4,7 @@ try:
from urllib import request as urllib2 from urllib import request as urllib2
except ImportError: except ImportError:
import urllib2 import urllib2
from unittest import SkipTest
import socket import socket
import ssl import ssl
...@@ -89,54 +89,5 @@ class Test_wsgiserver(util.TestServer): ...@@ -89,54 +89,5 @@ class Test_wsgiserver(util.TestServer):
def test_a_blocking_client(self): def test_a_blocking_client(self):
self._do_test_a_blocking_client() self._do_test_a_blocking_client()
@greentest.skipOnCI("Timing issues sometimes lead to a connection refused")
class Test_wsgiserver_ssl(Test_wsgiserver):
server = 'wsgiserver_ssl.py'
URL = 'https://%s:8443' % (params.DEFAULT_LOCAL_HOST_ADDR,)
PORT = 8443
_use_ssl = True
if hasattr(ssl, '_create_unverified_context'):
# Disable verification for our self-signed cert
# on Python >= 2.7.9 and 3.4
ssl_ctx = ssl._create_unverified_context()
@greentest.skipOnCI("Timing issues sometimes lead to a connection refused")
@greentest.skipWithoutExternalNetwork("Tries to reach google.com")
class Test_webproxy(Test_wsgiserver):
server = 'webproxy.py'
def _run_all_tests(self):
status, data = self.read('/')
self.assertEqual(status, '200 OK')
self.assertIn(b"gevent example", data)
status, data = self.read('/http://www.google.com')
self.assertEqual(status, '200 OK')
self.assertIn(b'google', data.lower())
def test_a_blocking_client(self):
# Not applicable
raise SkipTest("Not applicable")
# class Test_webpy(Test_wsgiserver):
# server = 'webpy.py'
# not_found_message = 'not found'
#
# def _test_hello(self):
# status, data = self.read('/')
# self.assertEqual(status, '200 OK')
# assert "Hello, world" in data, repr(data)
#
# def _test_long(self):
# start = time.time()
# status, data = self.read('/long')
# delay = time.time() - start
# assert 10 - 0.5 < delay < 10 + 0.5, delay
# self.assertEqual(status, '200 OK')
# self.assertEqual(data, 'Hello, 10 seconds later')
if __name__ == '__main__': if __name__ == '__main__':
greentest.main() greentest.main()
import ssl
import gevent.testing as greentest
from gevent.testing import params
from . import test__example_wsgiserver
@greentest.skipOnCI("Timing issues sometimes lead to a connection refused")
class Test_wsgiserver_ssl(test__example_wsgiserver.Test_wsgiserver):
server = 'wsgiserver_ssl.py'
URL = 'https://%s:8443' % (params.DEFAULT_LOCAL_HOST_ADDR,)
PORT = 8443
_use_ssl = True
if hasattr(ssl, '_create_unverified_context'):
# Disable verification for our self-signed cert
# on Python >= 2.7.9 and 3.4
ssl_ctx = ssl._create_unverified_context()
if __name__ == '__main__':
greentest.main()
...@@ -27,19 +27,11 @@ def _find_files_to_ignore(): ...@@ -27,19 +27,11 @@ def _find_files_to_ignore():
try: try:
os.chdir(this_dir) os.chdir(this_dir)
# These three are all tested with test___example_servers. result = [x[14:] for x in glob.glob('test__example_*.py')]
# TODO: Refactor those to regular test__example_*foo* files.
result = [
'wsgiserver.py',
'wsgiserver_ssl.py',
'webproxy.py',
]
if greentest.PYPY and greentest.RUNNING_ON_APPVEYOR: if greentest.PYPY and greentest.RUNNING_ON_APPVEYOR:
# For some reason on Windows with PyPy, this times out, # For some reason on Windows with PyPy, this times out,
# when it should be very fast. # when it should be very fast.
result.append("processes.py") result.append("processes.py")
result += [x[14:] for x in glob.glob('test__example_*.py')]
finally: finally:
os.chdir(old_dir) os.chdir(old_dir)
......
test___example_servers.py test___config.py
test___ident.py
test___monitor.py
test__ares_timeout.py
test__backdoor.py test__backdoor.py
test__close_backend_fd.py
test__events.py
test__example_echoserver.py test__example_echoserver.py
test__example_portforwarder.py
test__example_udp_client.py test__example_udp_client.py
test__example_wsgiserver.py
test__example_wsgiserver_ssl.py
test__example_webproxy.py
test__examples.py
test__getaddrinfo_import.py test__getaddrinfo_import.py
test__example_portforwarder.py test__hub_join.py
test__hub_join_timeout.py
test__issue330.py
test__iwait.py
test__monkey_scope.py
test__pywsgi.py test__pywsgi.py
test__server.py test__server.py
test__server_pywsgi.py test__server_pywsgi.py
...@@ -12,15 +26,3 @@ test__socket_dns6.py ...@@ -12,15 +26,3 @@ test__socket_dns6.py
test__socket_errors.py test__socket_errors.py
test__socket_send_memoryview.py test__socket_send_memoryview.py
test__socket_timeout.py test__socket_timeout.py
test__examples.py
test__issue330.py
test___ident.py
test___config.py
test___monitor.py
test__events.py
test__monkey_scope.py
test__iwait.py
test__ares_timeout.py
test__close_backend_fd.py
test__hub_join.py
test__hub_join_timeout.py
...@@ -18,7 +18,7 @@ test__environ.py ...@@ -18,7 +18,7 @@ test__environ.py
test__event.py test__event.py
# uses socket test__example_echoserver.py # uses socket test__example_echoserver.py
# uses socket test__example_portforwarder.py # uses socket test__example_portforwarder.py
# uses socket test___example_servers.py # uses socket test__example_w*.py
# uses bunch of things test__examples.py # uses bunch of things test__examples.py
# uses socket test__example_udp_client.py # uses socket test__example_udp_client.py
# uses socket test__example_udp_server.py # uses socket test__example_udp_server.py
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment