Commit 7960b8c3 authored by Jason Madden's avatar Jason Madden

CPython2.7 has only one expected failure now. Fixes test_ares_timeout and test_httpservers.

parent c8e473aa
...@@ -202,9 +202,15 @@ class SSLSocket(socket): ...@@ -202,9 +202,15 @@ class SSLSocket(socket):
# mixed in. # mixed in.
if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM: if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
raise NotImplementedError("only stream sockets are supported") raise NotImplementedError("only stream sockets are supported")
socket.__init__(self, _sock=sock)
if PYPY: if PYPY:
socket.__init__(self, _sock=sock)
sock._drop() sock._drop()
else:
# CPython: XXX: Must pass the underlying socket, not our
# potential wrapper; test___example_servers fails the SSL test
# with a client-side EOF error. (Why?)
socket.__init__(self, _sock=sock._sock)
# The initializer for socket overrides the methods send(), recv(), etc. # The initializer for socket overrides the methods send(), recv(), etc.
# in the instancce, which we don't need -- but we want to provide the # in the instancce, which we don't need -- but we want to provide the
......
...@@ -418,6 +418,8 @@ class CGIHTTPServerTestCase(BaseTestCase): ...@@ -418,6 +418,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
finally: finally:
BaseTestCase.tearDown(self) BaseTestCase.tearDown(self)
@unittest.skipIf(hasattr(CGIHTTPServer, '_url_collapse_path'),
"Only on <= 2.7.3")
def test_url_collapse_path_split(self): def test_url_collapse_path_split(self):
test_vectors = { test_vectors = {
'': ('/', ''), '': ('/', ''),
...@@ -457,6 +459,50 @@ class CGIHTTPServerTestCase(BaseTestCase): ...@@ -457,6 +459,50 @@ class CGIHTTPServerTestCase(BaseTestCase):
msg='path = %r\nGot: %r\nWanted: %r' % msg='path = %r\nGot: %r\nWanted: %r' %
(path, actual, expected)) (path, actual, expected))
@unittest.skipIf(hasattr(CGIHTTPServer, '_url_collapse_path_split'),
"Only on >= 2.7.3")
def test_url_collapse_path(self):
# verify tail is the last portion and head is the rest on proper urls
test_vectors = {
'': '//',
'..': IndexError,
'/.//..': IndexError,
'/': '//',
'//': '//',
'/\\': '//\\',
'/.//': '//',
'cgi-bin/file1.py': '/cgi-bin/file1.py',
'/cgi-bin/file1.py': '/cgi-bin/file1.py',
'a': '//a',
'/a': '//a',
'//a': '//a',
'./a': '//a',
'./C:/': '/C:/',
'/a/b': '/a/b',
'/a/b/': '/a/b/',
'/a/b/.': '/a/b/',
'/a/b/c/..': '/a/b/',
'/a/b/c/../d': '/a/b/d',
'/a/b/c/../d/e/../f': '/a/b/d/f',
'/a/b/c/../d/e/../../f': '/a/b/f',
'/a/b/c/../d/e/.././././..//f': '/a/b/f',
'../a/b/c/../d/e/.././././..//f': IndexError,
'/a/b/c/../d/e/../../../f': '/a/f',
'/a/b/c/../d/e/../../../../f': '//f',
'/a/b/c/../d/e/../../../../../f': IndexError,
'/a/b/c/../d/e/../../../../f/..': '//',
'/a/b/c/../d/e/../../../../f/../.': '//',
}
for path, expected in test_vectors.iteritems():
if isinstance(expected, type) and issubclass(expected, Exception):
self.assertRaises(expected,
CGIHTTPServer._url_collapse_path, path)
else:
actual = CGIHTTPServer._url_collapse_path(path)
self.assertEqual(expected, actual,
msg='path = %r\nGot: %r\nWanted: %r' %
(path, actual, expected))
def test_headers_and_content(self): def test_headers_and_content(self):
res = self.request('/cgi-bin/file1.py') res = self.request('/cgi-bin/file1.py')
self.assertEqual(('Hello World\n', 'text/html', 200), self.assertEqual(('Hello World\n', 'text/html', 200),
......
from __future__ import print_function from __future__ import print_function
import sys import sys
import errno
import gevent import gevent
try: try:
from gevent.resolver_ares import Resolver from gevent.resolver_ares import Resolver
...@@ -14,7 +15,7 @@ listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ...@@ -14,7 +15,7 @@ listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try: try:
listener.bind(address) listener.bind(address)
except socket.error as ex: except socket.error as ex:
if 'permission denied' in str(ex).lower(): if ex.errno in (errno.EPERM, errno.EADDRNOTAVAIL) or 'permission denied' in str(ex).lower():
sys.stderr.write('This test binds on port 53 and thus must be run as root.\n') sys.stderr.write('This test binds on port 53 and thus must be run as root.\n')
sys.exit(0) sys.exit(0)
raise raise
......
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