Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make test not working #318

Open
christopher-gray-vca opened this issue May 22, 2020 · 2 comments
Open

make test not working #318

christopher-gray-vca opened this issue May 22, 2020 · 2 comments

Comments

@christopher-gray-vca
Copy link

platform linux2 -- Python 2.7.16, pytest-4.6.10, py-1.8.1, pluggy-0.13.1 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /home/vcacadmin/oncall-master
plugins: mock-2.0.0
collected 11 items / 1 errors / 10 selected

========================================================================================================================================== ERRORS ===========================================================================================================================================
____________________________________________________________________________________________________________________________ ERROR collecting test/test_auth.py _____________________________________________________________________________________________________________________________
ImportError while importing test module '/home/vcacadmin/oncall-master/test/test_auth.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/test_auth.py:2: in
from oncall.app import ReqBodyMiddleware
src/oncall/app.py:3: in
from urllib.parse import unquote_plus
E ImportError: No module named parse
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================================================================== 1 error in 0.37 seconds ==================================================================================================================================
make[1]: *** [Makefile:7: unit] Error 2
make[1]: Leaving directory '/home/vcacadmin/oncall-master'
make: *** [Makefile:13: test] Error 2
vcacadmin@caoncall:~/oncall-master$

@houqp
Copy link
Contributor

houqp commented May 22, 2020

Looks like you are using python 2, please try python 3 instead.

@The-Hunt-arch
Copy link

if new_retry.is_exhausted():

      raise MaxRetryError(_pool, url, error or ResponseError(cause))

E urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /api/v0/users (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa2f64d04c0>: Failed to establish a new connection: [Errno 111] Connection refused'))

/usr/lib/python3/dist-packages/urllib3/util/retry.py:436: MaxRetryError

During handling of the above exception, another exception occurred:

@pytest.fixture(scope="session", autouse=True)
def require_test_user():
  re = requests.post(api_v0('users'), json={'name': 'test_user'})

e2e/conftest.py:26:


/usr/lib/python3/dist-packages/requests/api.py:116: in post
return request('post', url, data=data, json=json, **kwargs)
/usr/lib/python3/dist-packages/requests/api.py:60: in request
return session.request(method=method, url=url, **kwargs)
/usr/lib/python3/dist-packages/requests/sessions.py:533: in request
resp = self.send(prep, **send_kwargs)
/usr/lib/python3/dist-packages/requests/sessions.py:646: in send
r = adapter.send(request, **kwargs)


self = <requests.adapters.HTTPAdapter object at 0x7fa2f66c5e50>
request = <PreparedRequest [POST]>, stream = False
timeout = <urllib3.util.timeout.Timeout object at 0x7fa2f653af40>
verify = True, cert = None, proxies = OrderedDict()

def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
    """Sends PreparedRequest object. Returns Response object.

    :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
    :param stream: (optional) Whether to stream the request content.
    :param timeout: (optional) How long to wait for the server to send
        data before giving up, as a float, or a :ref:`(connect timeout,
        read timeout) <timeouts>` tuple.
    :type timeout: float or tuple or urllib3 Timeout object
    :param verify: (optional) Either a boolean, in which case it controls whether
        we verify the server's TLS certificate, or a string, in which case it
        must be a path to a CA bundle to use
    :param cert: (optional) Any user-provided SSL certificate to be trusted.
    :param proxies: (optional) The proxies dictionary to apply to the request.
    :rtype: requests.Response
    """

    try:
        conn = self.get_connection(request.url, proxies)
    except LocationValueError as e:
        raise InvalidURL(e, request=request)

    self.cert_verify(conn, request.url, verify, cert)
    url = self.request_url(request, proxies)
    self.add_headers(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)

    chunked = not (request.body is None or 'Content-Length' in request.headers)

    if isinstance(timeout, tuple):
        try:
            connect, read = timeout
            timeout = TimeoutSauce(connect=connect, read=read)
        except ValueError as e:
            # this may raise a string formatting error.
            err = ("Invalid timeout {}. Pass a (connect, read) "
                   "timeout tuple, or a single float to set "
                   "both timeouts to the same value".format(timeout))
            raise ValueError(err)
    elif isinstance(timeout, TimeoutSauce):
        pass
    else:
        timeout = TimeoutSauce(connect=timeout, read=timeout)

    try:
        if not chunked:
            resp = conn.urlopen(
                method=request.method,
                url=url,
                body=request.body,
                headers=request.headers,
                redirect=False,
                assert_same_host=False,
                preload_content=False,
                decode_content=False,
                retries=self.max_retries,
                timeout=timeout
            )

        # Send the request.
        else:
            if hasattr(conn, 'proxy_pool'):
                conn = conn.proxy_pool

            low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)

            try:
                low_conn.putrequest(request.method,
                                    url,
                                    skip_accept_encoding=True)

                for header, value in request.headers.items():
                    low_conn.putheader(header, value)

                low_conn.endheaders()

                for i in request.body:
                    low_conn.send(hex(len(i))[2:].encode('utf-8'))
                    low_conn.send(b'\r\n')
                    low_conn.send(i)
                    low_conn.send(b'\r\n')
                low_conn.send(b'0\r\n\r\n')

                # Receive the response from the server
                try:
                    # For Python 2.7, use buffering of HTTP responses
                    r = low_conn.getresponse(buffering=True)
                except TypeError:
                    # For compatibility with Python 3.3+
                    r = low_conn.getresponse()

                resp = HTTPResponse.from_httplib(
                    r,
                    pool=conn,
                    connection=low_conn,
                    preload_content=False,
                    decode_content=False
                )
            except:
                # If we hit any problems here, clean up the connection.
                # Then, reraise so that we can handle the actual exception.
                low_conn.close()
                raise

    except (ProtocolError, socket.error) as err:
        raise ConnectionError(err, request=request)

    except MaxRetryError as e:
        if isinstance(e.reason, ConnectTimeoutError):
            # TODO: Remove this in 3.0.0: see #2811
            if not isinstance(e.reason, NewConnectionError):
                raise ConnectTimeout(e, request=request)

        if isinstance(e.reason, ResponseError):
            raise RetryError(e, request=request)

        if isinstance(e.reason, _ProxyError):
            raise ProxyError(e, request=request)

        if isinstance(e.reason, _SSLError):
            # This branch is for urllib3 v1.22 and later.
            raise SSLError(e, request=request)
      raise ConnectionError(e, request=request)

E requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /api/v0/users (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa2f64d04c0>: Failed to establish a new connection: [Errno 111] Connection refused'))

/usr/lib/python3/dist-packages/requests/adapters.py:516: ConnectionError
_________________ ERROR at setup of test_api_v0_team_members __________________

self = <urllib3.connection.HTTPConnection object at 0x7fa2f64d04c0>

def _new_conn(self):
    """ Establish a socket connection and set nodelay settings on it.

    :return: New socket connection.
    """
    extra_kw = {}
    if self.source_address:
        extra_kw["source_address"] = self.source_address

    if self.socket_options:
        extra_kw["socket_options"] = self.socket_options

    try:
      conn = connection.create_connection(
            (self._dns_host, self.port), self.timeout, **extra_kw
        )

/usr/lib/python3/dist-packages/urllib3/connection.py:159:


address = ('localhost', 8080), timeout = None, source_address = None
socket_options = [(6, 1, 1)]

def create_connection(
    address,
    timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
    source_address=None,
    socket_options=None,
):
    """Connect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    """

    host, port = address
    if host.startswith("["):
        host = host.strip("[]")
    err = None

    # Using the value from allowed_gai_family() in the context of getaddrinfo lets
    # us select whether to work with IPv4 DNS records, IPv6 records, or both.
    # The original create_connection function always returns all records.
    family = allowed_gai_family()

    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
        af, socktype, proto, canonname, sa = res
        sock = None
        try:
            sock = socket.socket(af, socktype, proto)

            # If provided, set socket level options before connecting.
            _set_socket_options(sock, socket_options)

            if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
                sock.settimeout(timeout)
            if source_address:
                sock.bind(source_address)
            sock.connect(sa)
            return sock

        except socket.error as e:
            err = e
            if sock is not None:
                sock.close()
                sock = None

    if err is not None:
      raise err

/usr/lib/python3/dist-packages/urllib3/util/connection.py:84:


address = ('localhost', 8080), timeout = None, source_address = None
socket_options = [(6, 1, 1)]

def create_connection(
    address,
    timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
    source_address=None,
    socket_options=None,
):
    """Connect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    """

    host, port = address
    if host.startswith("["):
        host = host.strip("[]")
    err = None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants