test/__init__.py
def requires_network(test):
    """Helps you skip tests that require the network"""

    def _is_unreachable_err(err):
        return getattr(err, 'errno', None) in (errno.ENETUNREACH,
                                               errno.EHOSTUNREACH) # For OSX

    @functools.wraps(test)
    def wrapper(*args, **kwargs):
        msg = "Can't run {name} because the network is unreachable".format(
            name=test.__name__)
        try:
            return test(*args, **kwargs)
        except socket.error as e:
            # This test needs an initial network connection to attempt the
            # connection to the TARPIT_HOST. This fails if you are in a place
            # without an Internet connection, so we skip the test in that case.
            if _is_unreachable_err(e):
                raise SkipTest(msg)
            raise
        except MaxRetryError as e:
            if (isinstance(e.reason, socket.error) and
                _is_unreachable_err(e.reason)):
                raise SkipTest(msg)
            raise
    return wrapper
Helps you skip tests that require the network
Helps you skip tests that require the network
Helps you skip tests that require the network
def requires_network(test):
    def _is_unreachable_err(err):
        return getattr(err, 'errno', None) in (errno.ENETUNREACH,
                                               errno.EHOSTUNREACH) 
    @functools.wraps(test)
    def wrapper(*args, **kwargs):
        msg = "Can't run {name} because the network is unreachable".format(
            name=test.__name__)
        try:
            return test(*args, **kwargs)
        except socket.error as e:
            if _is_unreachable_err(e):
                raise SkipTest(msg)
            raise
        except MaxRetryError as e:
            if (isinstance(e.reason, socket.error) and
                _is_unreachable_err(e.reason)):
                raise SkipTest(msg)
            raise
    return wrapper
def requires_network ( test ) : def _is_unreachable_err ( err ) : return getattr ( err , 'errno' , None ) in ( errno . ENETUNREACH , errno . EHOSTUNREACH ) @ functools . wraps ( test ) def wrapper ( * args , ** kwargs ) : msg = "Can't run {name} because the network is unreachable" . format ( name = test . __name__ ) try : return test ( * args , ** kwargs ) except socket . error as e : if _is_unreachable_err ( e ) : raise SkipTest ( msg ) raise except MaxRetryError as e : if ( isinstance ( e . reason , socket . error ) and _is_unreachable_err ( e . reason ) ) : raise SkipTest ( msg ) raise return wrapper
Helps you skip tests that require the network
Helps you skip tests that require the network
"""Helps you skip tests that require the network""" # For OSX # This test needs an initial network connection to attempt the # connection to the TARPIT_HOST. This fails if you are in a place # without an Internet connection, so we skip the test in that case.
test