diff --git a/docs_src/security/tutorial004.py b/docs_src/security/tutorial004.py index 222589618..c7dc8bae0 100644 --- a/docs_src/security/tutorial004.py +++ b/docs_src/security/tutorial004.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import Union import jwt @@ -53,6 +54,7 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial004_an.py b/docs_src/security/tutorial004_an.py index e2221cd39..e6bf24247 100644 --- a/docs_src/security/tutorial004_an.py +++ b/docs_src/security/tutorial004_an.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import Union import jwt @@ -54,6 +55,7 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial004_an_py310.py b/docs_src/security/tutorial004_an_py310.py index a3f74fc0e..862244478 100644 --- a/docs_src/security/tutorial004_an_py310.py +++ b/docs_src/security/tutorial004_an_py310.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import Annotated import jwt @@ -53,6 +54,7 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial004_an_py39.py b/docs_src/security/tutorial004_an_py39.py index b33d677ed..baaf529a2 100644 --- a/docs_src/security/tutorial004_an_py39.py +++ b/docs_src/security/tutorial004_an_py39.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import Annotated, Union import jwt @@ -53,6 +54,7 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial004_py310.py b/docs_src/security/tutorial004_py310.py index d46ce26bf..354dd7c7d 100644 --- a/docs_src/security/tutorial004_py310.py +++ b/docs_src/security/tutorial004_py310.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache import jwt from fastapi import Depends, FastAPI, HTTPException, status @@ -52,6 +53,7 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial005.py b/docs_src/security/tutorial005.py index ccad07969..983c65dc2 100644 --- a/docs_src/security/tutorial005.py +++ b/docs_src/security/tutorial005.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import List, Union import jwt @@ -68,6 +69,7 @@ oauth2_scheme = OAuth2PasswordBearer( app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial005_an.py b/docs_src/security/tutorial005_an.py index 2e8bb3bdb..b83d61f5d 100644 --- a/docs_src/security/tutorial005_an.py +++ b/docs_src/security/tutorial005_an.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import List, Union import jwt @@ -69,6 +70,7 @@ oauth2_scheme = OAuth2PasswordBearer( app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial005_an_py310.py b/docs_src/security/tutorial005_an_py310.py index 90781587f..0e21cbfea 100644 --- a/docs_src/security/tutorial005_an_py310.py +++ b/docs_src/security/tutorial005_an_py310.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import Annotated import jwt @@ -68,6 +69,7 @@ oauth2_scheme = OAuth2PasswordBearer( app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial005_an_py39.py b/docs_src/security/tutorial005_an_py39.py index a5192d8d6..f13e8160e 100644 --- a/docs_src/security/tutorial005_an_py39.py +++ b/docs_src/security/tutorial005_an_py39.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import Annotated, Union import jwt @@ -68,6 +69,7 @@ oauth2_scheme = OAuth2PasswordBearer( app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial005_py310.py b/docs_src/security/tutorial005_py310.py index b244ef08e..1d8b9c8ef 100644 --- a/docs_src/security/tutorial005_py310.py +++ b/docs_src/security/tutorial005_py310.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache import jwt from fastapi import Depends, FastAPI, HTTPException, Security, status @@ -67,6 +68,7 @@ oauth2_scheme = OAuth2PasswordBearer( app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/docs_src/security/tutorial005_py39.py b/docs_src/security/tutorial005_py39.py index 8f0e93376..fa0761eb0 100644 --- a/docs_src/security/tutorial005_py39.py +++ b/docs_src/security/tutorial005_py39.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta, timezone +from functools import lru_cache from typing import Union import jwt @@ -68,6 +69,7 @@ oauth2_scheme = OAuth2PasswordBearer( app = FastAPI() +@lru_cache def verify_password(plain_password, hashed_password): return pwd_context.verify(plain_password, hashed_password) diff --git a/tests/test_tutorial/test_sql_databases/test_tutorial001.py b/tests/test_tutorial/test_sql_databases/test_tutorial001.py index cc7e590df..2a1343503 100644 --- a/tests/test_tutorial/test_sql_databases/test_tutorial001.py +++ b/tests/test_tutorial/test_sql_databases/test_tutorial001.py @@ -29,6 +29,7 @@ def clear_sqlmodel(): pytest.param("tutorial001_an_py39", marks=needs_py39), pytest.param("tutorial001_an_py310", marks=needs_py310), ], + scope="module", ) def get_client(request: pytest.FixtureRequest): clear_sqlmodel() diff --git a/tests/test_tutorial/test_sql_databases/test_tutorial002.py b/tests/test_tutorial/test_sql_databases/test_tutorial002.py index 79e48c1c3..19e0f98a5 100644 --- a/tests/test_tutorial/test_sql_databases/test_tutorial002.py +++ b/tests/test_tutorial/test_sql_databases/test_tutorial002.py @@ -29,6 +29,7 @@ def clear_sqlmodel(): pytest.param("tutorial002_an_py39", marks=needs_py39), pytest.param("tutorial002_an_py310", marks=needs_py310), ], + scope="module", ) def get_client(request: pytest.FixtureRequest): clear_sqlmodel()