Browse Source

Remove code examples for Python 3.8 in `authentication_error_status_code`

pull/14510/head
Yurii Motov 7 months ago
parent
commit
3b563725ee
  1. 20
      docs_src/authentication_error_status_code/tutorial001_an.py
  2. 5
      tests/test_tutorial/test_authentication_error_status_code/test_tutorial001.py

20
docs_src/authentication_error_status_code/tutorial001_an.py

@ -1,20 +0,0 @@
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from typing_extensions import Annotated
app = FastAPI()
class HTTPBearer403(HTTPBearer):
def make_not_authenticated_error(self) -> HTTPException:
return HTTPException(
status_code=status.HTTP_403_FORBIDDEN, detail="Not authenticated"
)
CredentialsDep = Annotated[HTTPAuthorizationCredentials, Depends(HTTPBearer403())]
@app.get("/me")
def read_me(credentials: CredentialsDep):
return {"message": "You are authenticated", "token": credentials.credentials}

5
tests/test_tutorial/test_authentication_error_status_code/test_tutorial001.py

@ -4,14 +4,11 @@ import pytest
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from ...utils import needs_py39
@pytest.fixture(
name="client",
params=[
"tutorial001_an",
pytest.param("tutorial001_an_py39", marks=needs_py39),
"tutorial001_an_py39",
],
)
def get_client(request: pytest.FixtureRequest):

Loading…
Cancel
Save