/flask-pytest-example

Small example of a Flask app using pytest to test routing and requests, GET and POST

Primary LanguagePythonMIT LicenseMIT

Flask Pytest routing and requests example

Simple sample application demonstrating how to use Pytest with Flask for testing routing and requests. The example includes a basic "hello world" route to demonstrate a GET request. Using local Pytest api plugin.

Setup and run instructions

# Not needed if using GitPod
git clone https://github.com/alanwilter/flask-pytest-example
cd flask-pytest-example
python3 -m venv venv
source venv/bin/activate
# end GitPod

pip install --upgrade pip
pip install -r requirements.txt

# Start app to check if it's OK
python app.py
# crtl-c

# Then run:
pytest --cov handlers --cov-report term-missing -k via -sv

# handlers/routes.py           6      0   100%

This now works with pytest-cov where pytest and app service run in separated processes.