Код IT
← Каталог

Тестирование на pytest — Flask — тестовый клиент

Фрагмент из «Тестирование на pytest»: Flask — тестовый клиент.

Python main.py

import pytest

from app import app

@pytest.fixture
def client():
    app.config["TESTING"] = True
    with app.test_client() as c:
        yield c


def test_index(client):
    r = client.get("/")
    assert r.status_code == 200

import pytest

from app import app

@pytest.fixture
def client():
    app.config["TESTING"] = True
    with app.test_client() as c:
        yield c


def test_index(client):
    r = client.get("/")
    assert r.status_code == 200