Ejemplo n.º 1
0
def test_timeout():
    test_support.requires('network')

    def error_msg(extra_msg):
        print >> sys.stderr, """\
    WARNING:  an attempt to connect to %r %s, in
    test_timeout.  That may be legitimate, but is not the outcome we hoped
    for.  If this message is seen often, test_timeout should be changed to
    use a more reliable address.""" % (ADDR, extra_msg)

    if test_support.verbose:
        print "test_timeout ..."

    # A service which issues a welcome banner (without need to write
    # anything).
    ADDR = "pop.gmail.com", 995

    s = socket.socket()
    s.settimeout(30.0)
    try:
        s.connect(ADDR)
    except socket.timeout:
        error_msg('timed out')
        return
    except socket.error, exc:  # In case connection is refused.
        if exc.args[0] == errno.ECONNREFUSED:
            error_msg('was refused')
            return
        else:
            raise
Ejemplo n.º 2
0
def test_timeout():
    test_support.requires('network')

    def error_msg(extra_msg):
        print >> sys.stderr, """\
    WARNING:  an attempt to connect to %r %s, in
    test_timeout.  That may be legitimate, but is not the outcome we hoped
    for.  If this message is seen often, test_timeout should be changed to
    use a more reliable address.""" % (ADDR, extra_msg)

    if test_support.verbose:
        print "test_timeout ..."

    # A service which issues a welcome banner (without need to write
    # anything).
    ADDR = "pop.gmail.com", 995

    s = socket.socket()
    s.settimeout(30.0)
    try:
        s.connect(ADDR)
    except socket.timeout:
        error_msg('timed out')
        return
    except socket.error, exc:  # In case connection is refused.
        if exc.args[0] == errno.ECONNREFUSED:
            error_msg('was refused')
            return
        else:
            raise
Ejemplo n.º 3
0
def test_basic():
    test_support.requires('network')

    from eventlet.green import urllib

    if test_support.verbose:
        print "test_basic ..."

    socket.RAND_status()
    socket.RAND_add("this is a random string", 75.0)

    try:
        f = urllib.urlopen('https://sf.net')
    except IOError, exc:
        if exc.errno == errno.ETIMEDOUT:
            raise test_support.ResourceDenied('HTTPS connection is timing out')
        else:
            raise
Ejemplo n.º 4
0
def test_basic():
    test_support.requires('network')

    from eventlet.green import urllib

    if test_support.verbose:
        print "test_basic ..."

    socket.RAND_status()
    socket.RAND_add("this is a random string", 75.0)

    try:
        f = urllib.urlopen('https://sf.net')
    except IOError, exc:
        if exc.errno == errno.ETIMEDOUT:
            raise test_support.ResourceDenied('HTTPS connection is timing out')
        else:
            raise
Ejemplo n.º 5
0
def test_main():
    test_support.requires('network')
    test_support.run_unittest(CreationTestCase, TimeoutTestCase)
Ejemplo n.º 6
0
# Test suite for SocketServer.py
# converted to unittest (Denis)

from greentest import test_support
from greentest.test_support import (verbose, verify, TESTFN, TestSkipped,
                                    reap_children)
test_support.requires('network')

from eventlib.green.SocketServer import *
from eventlib.green import socket
import errno
from eventlib.green import select
from eventlib.green import time
from eventlib.green import threading
import sys
import os
import unittest

NREQ = 3
DELAY = 0.05


class MyMixinHandler:
    def handle(self):
        time.sleep(DELAY)
        line = self.rfile.readline()
        time.sleep(DELAY)
        self.wfile.write(line)


class MyStreamHandler(MyMixinHandler, StreamRequestHandler):
Ejemplo n.º 7
0
def test_main():
    test_support.requires('network')
    test_support.run_unittest(CreationTestCase, TimeoutTestCase)
# Test suite for SocketServer.py
# converted to unittest (Denis)

from greentest import test_support
from greentest.test_support import verbose, verify, TESTFN, TestSkipped, reap_children

test_support.requires("network")

from eventlet.green.SocketServer import *
from eventlet.green import socket
import errno
from eventlet.green import select
from eventlet.green import time
from eventlet.green import threading
import sys
import os
import unittest

NREQ = 3
DELAY = 0.05


class MyMixinHandler:
    def handle(self):
        time.sleep(DELAY)
        line = self.rfile.readline()
        time.sleep(DELAY)
        self.wfile.write(line)


class MyStreamHandler(MyMixinHandler, StreamRequestHandler):