mirror of https://github.com/tiangolo/fastapi.git
26 lines
528 B
Python
26 lines
528 B
Python
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
app = FastAPI(title="Example App")
|
|
|
|
|
|
@app.get("/a/b")
|
|
async def get_shuli_in_a_pita():
|
|
return {"a": "b"}
|
|
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_elements_uit():
|
|
response = client.get("/elements")
|
|
assert response.status_code == 200, response.text
|
|
print(response.text)
|
|
assert app.title in response.text
|
|
assert "Stoplight" in response.text
|
|
|
|
|
|
def test_response():
|
|
response = client.get("/a/b")
|
|
assert response.json() == {"a": "b"}
|