1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
# -*- coding: utf-8 -*-
# @Author : llc
# @Time : 2022/9/7 9:46
import pytest
from flask import request
from flask_openapi3 import OpenAPI
app = OpenAPI(__name__)
@app.get("/t")
@app.get("/tt")
def get_t():
return request.url
@app.post("/t")
@app.post("/tt")
def post_t():
return request.url
@pytest.fixture
def client():
client = app.test_client()
return client
def test_get_t(client):
r = client.get("/t")
assert r.text == "http://localhost/t"
r = client.get("/tt")
assert r.text == "http://localhost/tt"
def test_post_t(client):
r = client.post("/t")
assert r.text == "http://localhost/t"
r = client.post("/tt")
assert r.text == "http://localhost/tt"
|