Following the tutorial on

This is notes following mjhea0 tutorial

mkdir flaskr-tdd

cd flaskr-tdd

Create Python environment

python3 -m venv env


Install flask Python minimal web framework

pip install flask==1.1.2

Install PyTest testing framework

pip install pytest==6.1.1

Create project skeleton structure

mkdir project
mkdir tests
touch project/
touch project/
touch tests/
touch tests/

Write py according to tutorial.

from flask import Flask # Import Flask web framework

# init flask application
app = Flask(__name__)

# Add root url route
def hello():
    return "Hello, World!" # Return hello world from root URL

# Run the Flask application
if __name__ == "__main__":

Write tests/ accordint to tutorial.

from import app

# Index test
def test_index():
    tester = app.test_client()
    response = tester.get("/", content_type="html/text") # Get root url
    # Check that we get status code 200 back
    assert response.status_code == 200 # 
    # Check that the result is "Hello, World"
    assert == b"Hello, World!"

Getting issue with obsolete json from Flask

  /home/chris/src/python/flaskr-tdd/env/lib/python3.7/site-packages/flask/json/ DeprecationWarning: Importing 'itsdangerous.json' is deprecated and will be removed in ItsDangerous 2.1. Use Python's 'json' module instead.
    class JSONDecoder(_json.JSONDecoder):

-- Docs:
================================ 1 passed, 3 warnings in 0.09s =================================

Fixing issue by upgrading Flask and Pytest

pip install pytest
pip install flask

Getting passing Python unit tests

python -m pytest
===================================== test session starts ======================================
platform linux -- Python 3.7.3, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: /home/chris/src/python/flaskr-tdd
collected 1 item                                                                               

tests/ .                                                                      [100%]

====================================== 1 passed in 0.09s =======================================