First of all I am aware of flask-testing library with LiveServerTestCase
class but it hasn't updated since 2017 and GitHub full of issues of it not working neither on Windows or MacOs and I haven't found any other solutions.
I am trying to write some tests for flask app using selenium to validate FlaskForms inside this app.
Simple test like this:
def test_start(app):
driver.get("http://127.0.0.1:5000/endpoint")
authenticate(driver)
falls on selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_CONNECTION_REFUSED
error. (As far as I understood in my case app creates in @pytest.fixtures and immediately shuts down and I need to find a way to keep it running for the whole test duration)
My question is: Is it possible to to create some live server in each test that will remain working so I could call API endpoints via selenium?
Simple fixtures if it helps:
@pytest.fixture
def app():
app = create_app()
...
with app.context():
# creating db
...
yield app
also:
@pytest.fixture
def client(app):
"""Test client"""
return app.test_client()