pytest-dev / pytest-timeout

MIT License
213 stars 64 forks source link

Flask pytest client.post request - timeout error #144

Closed davidjansa closed 1 year ago

davidjansa commented 1 year ago

Hello, I have problem with timeout errors only in client.post requests tests for Flask web app. Do you know how to fix this?

Run pytest --cov=web --cov-report=xml ============================= test session starts ============================== platform linux -- Python 3.10.6, pytest-7.2.2, pluggy-1.0.0

...

=================================== FAILURES =================================== ____ test_login_login_pageinvalid ____

client = <FlaskClient <Flask 'web'>>

def test_login_login_page_invalid(client):
    """test invaid http post request to /login_login route without valid data - should return login page title"""

> response = client.post("/login_login", data={}, follow_redirects=True)

tests/test_routes.py:52:


Error: def _select_servers_loop(self, selector, timeout, address): """select_servers() guts. Hold the lock when calling this.""" now = time.monotonic() end_time = now + timeout server_descriptions = self._description.apply_selector( selector, address, custom_selector=self._settings.server_selector )

    while not server_descriptions:
        # No suitable servers.
        if timeout == 0 or now > end_time:

> raise ServerSelectionTimeoutError( "%s, Timeout: %ss, Topology Description: %r" % (self._error_message(selector), timeout, self.description) )