Answer the question
In order to leave comments, you need to log in
How to raise a "Flask" application within testing when running autotests (Pytest)?
Reading the documentation, I can’t figure out how to implement it so that at the beginning of the test cycle the application is deployed and then there is testing of the REST API requests.
Usually, the application is deployed if you run the file with the following code:
from flask import redirect, send_from_directory, send_file
svc = GenericService(__name__, 'config')
app = svc.get_app()
app.add_api('./openapi/specifications.yml')
@app.app.route('/')
def home():
return redirect('/v1')
@app.app.route('/v1/f/<path:path>')
def send_frontend(path):
return send_from_directory('frontend', path)
@app.app.route('/f130')
def send_frontend_index():
return send_file('frontend/index.html', None, False, None, False, 0)
def create_app():
return app.run
# If we're running in stand alone mode, run the application
if __name__ == '__main__':
app.run(debug=True)
import pytest
@pytest.fixture
def app():
app = create_app()
return ap
def test_example(client):
response = client.get("/")
assert response.status_code == 200
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question