This Flask application contains the basic user management functionality (register, login, logout) to demonstrate the use of pytest.
After reading Brian Okken's book (Python Testing with pytest), I was convinced that I should learn about pytest and then figure out how to use it to test Flask applications.
In the top-level directory:
$ export FLASK_APP=app.py
$ export FLASK_ENV=development
$ flask run
Pull down the source code from this GitLab repository:
git clone [email protected]:patkennedy79/flask_user_management_example.git```
Create a new virtual environment:
```sh
$ cd flask_user_management_example
$ python3 -m venv venv
Activate the virtual environment:
$ source venv/bin/activate
Install the python packages in requirements.txt:
(venv) $ pip install -r requirements.txt
Set the file that contains the Flask application and specify that the development environment should be used:
(venv) $ export FLASK_APP=app.py
(venv) $ export FLASK_ENV=development
Run development server to serve the Flask application:
(venv) $ flask run
- Flask: micro-framework for web application development
- Jinga2 - templating engine
- SQLAlchemy - ORM (Object Relational Mapper)
- Flask-Bcrypt - password hashing
- Flask-Login - support for user management
- Flask-WTF - simplifies forms
This application is written using Python 3.8.5.
(venv) $ pytest -v