Outils pour utilisateurs

Outils du site


Panneau latéral

Plan du Site:

python:flask:testing

Testing

Intallation

pip install pytest

Structure

./my_project
    /app
        /static
            ...
        /templates
            ...
        /tests
            __init__.py              (fichier vide)
            test_articles.py
            test_fonctions.py
            test_divers.py
            ...
        __init__.py                (racine de l'application)

Tests

from ..services.tools import sub_month
import pytest, datetime
 
 
def test_sub_month_1():
    d1 = datetime.datetime(2023, 3, 15)
    d2 = sub_month(d1)
    assert d2.year  == 2023
    assert d2.month == 2
    assert d2.day   == 15

Exécution

pytest
python/flask/testing.txt · Dernière modification: 2024/03/07 12:27 par marclebrun