Questions tagged [flask-testing]
80 questions
3
votes
1 answer
Testing Flask -- Avoiding Circular Import
I have been using Django for a while but decided to give Flask a try for my latest side project. Because I did not want my entire app in one file, I followed the documentation here to make my Flask app into a package. Crucially, these instructions…

Two-Bit Alchemist
- 17,966
- 6
- 47
- 82
3
votes
1 answer
Test Coverage for Flask application doesnt work
Hi want to test the "delete route" in my flask application in terminal I can see that the test is past and it said "test_user_delete (test_app.LayoutTestCase) ... ok"
But when I open the cover page it still with red color which means doesn't cover…

LiLi
- 301
- 2
- 7
- 21
2
votes
0 answers
Unittest Airflow plugins
I have an airflow instance, and created some flask APIs as plugins. I am wondering if there is any way I can run some unittests for these APIs without them being dependent on Airflow?
from flask_appbuilder.api import BaseApi, expose
from flask…

Zselter07
- 71
- 5
2
votes
1 answer
How to override base url for Flask test client?
I want to test my flask application which is hosted on different machine (eg - staging machie to verify if all the api unit tests are passing), Can I override the flask base url in flask test client?
Currently all tests are run on DEV local…

Murtuza Z
- 5,639
- 1
- 28
- 52
2
votes
0 answers
Flask wtf forms is not populated with form data dict passed in the flask unittesting using Flask-Testing package
How to send form data in post request using Flask-flask_testing and flask_wtf packages?
This is my FlaskForm model and test function:
class BusinessTripProcessingForm(FlaskForm):
departure_time = DateTimeField('Exact departure date and time')
…

Matija Lukic
- 599
- 8
- 28
2
votes
0 answers
How to test POST request using flask_testing
I have a route for inserting a new project in a database.
@projects.route('/add_project', methods=['POST', 'GET'])
@login_required
def add_project():
form = request.form
customers = CustomerList.get_all(filters={'status': 'active'},…

Matija Lukic
- 599
- 8
- 28
2
votes
0 answers
Testing file upload with Flask test client
I'm testing two views and both of those views using the FileStorage object to save uploaded files from a post request.
During the tests I don't want to actually save the uploaded storage so I patch the FileStorage.save method using unittest's patch…

Szabolcs
- 3,990
- 18
- 38
2
votes
1 answer
How to avoid "ClientRedirectError: loop detected" error during testing Flask application (and how is it triggered)?
Environment:
Python 3.6.1
Flask 0.12.2
Werkzeug 0.14.1
While writing tests for my Flask application, I have discovered the following peculiarity: if in tests for Flask application you will be redirected to the same url two times 'in a row'…
user8554766
2
votes
1 answer
flask unit test "failed to establish a new connection"
I am writting unit tests for a flask app. This app expose REST endpoints and uses the flask_restful lib.
Basically, one of my endpoints will do requests to other endpoints and do some processing.
While executing the tests through pytest, it returns…

stockersky
- 1,531
- 2
- 20
- 36
2
votes
2 answers
How to setup testing script in Flask with SQLite?
I'm trying to do unit testing of my Flask web app. I'm use a pattern I saw in a Udemy class on Flask and a pattern similar to the Flask Mega-Tutorial online (http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vii-unit-testing). The…

Sourav Dey
- 387
- 1
- 4
- 14
2
votes
1 answer
Test a login required Flask application
I want to test a Flask app needs login to work i created the login test class:
class TestLogin(unittest.TestCase):
def setUp(self):
self.headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
def…

rezakamalifard
- 1,289
- 13
- 24
1
vote
2 answers
Flask can't import application from root directory to test
I have the following folder structure:
In the application.py file I am using a factory method create_app():
# application.py
def create_app():
flask_app = Flask(__name__)
return flask_app
app = create_app()
# --- Import Routes ---
from…

mmargo
- 31
- 1
- 5
1
vote
1 answer
Flask-testing database not saving on commit
I have the following flask factory directory setup:
server/
__init__.py
.env
wsgi.py
app/
__init__.py
config/
__init__.py
config.py
test_config.py
models/
…

ajrlewis
- 2,968
- 3
- 33
- 67
1
vote
0 answers
Why silencing the deprecation warning isn't working?
I'm trying to silence out Flask-SQLAlchemy's deprecation warning about adding overhead if used
with modification tracking:
config.py file:
class BaseConfig:
DEBUG = False
TESTING = False
SQLALCHEMY_DATABASE_URI = ''
…

appdeveloper
- 61
- 7
1
vote
1 answer
Get Flask-Testing server URL in setUpClass
I am writing unittest for my Flask web app using Selenium using Flask-Testing's LiveServer.
When running my test, I want to have one browser for all the tests instead of opening a new browser instance for each test, so I am using unittest's…

AcroTom
- 71
- 6