Postnov Roman 2 days ago
committed by GitHub
parent
commit
cddb461e64
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      tests/test_tutorial/test_security/test_tutorial005.py
  2. 1
      tests/test_tutorial/test_sql_databases/test_tutorial001.py
  3. 1
      tests/test_tutorial/test_sql_databases/test_tutorial002.py

16
tests/test_tutorial/test_security/test_tutorial005.py

@ -1,4 +1,5 @@
import importlib import importlib
from functools import lru_cache
from types import ModuleType from types import ModuleType
import pytest import pytest
@ -18,6 +19,7 @@ from ...utils import needs_py39, needs_py310
pytest.param("tutorial005_an_py39", marks=needs_py39), pytest.param("tutorial005_an_py39", marks=needs_py39),
pytest.param("tutorial005_an_py310", marks=needs_py310), pytest.param("tutorial005_an_py310", marks=needs_py310),
], ],
scope="module",
) )
def get_mod(request: pytest.FixtureRequest): def get_mod(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.security.{request.param}") mod = importlib.import_module(f"docs_src.security.{request.param}")
@ -25,6 +27,20 @@ def get_mod(request: pytest.FixtureRequest):
return mod return mod
@pytest.fixture(scope="module", autouse=True)
def cache_verify_password(mod: ModuleType):
assert hasattr(mod, "verify_password"), (
f"Module {mod.__name__} does not have attribute 'verify_password'"
)
original_func = mod.verify_password
cached_func = lru_cache()(original_func)
mod.verify_password = cached_func
yield
mod.verify_password = original_func
def get_access_token( def get_access_token(
*, username="johndoe", password="secret", scope=None, client: TestClient *, username="johndoe", password="secret", scope=None, client: TestClient
): ):

1
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_py39", marks=needs_py39),
pytest.param("tutorial001_an_py310", marks=needs_py310), pytest.param("tutorial001_an_py310", marks=needs_py310),
], ],
scope="module",
) )
def get_client(request: pytest.FixtureRequest): def get_client(request: pytest.FixtureRequest):
clear_sqlmodel() clear_sqlmodel()

1
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_py39", marks=needs_py39),
pytest.param("tutorial002_an_py310", marks=needs_py310), pytest.param("tutorial002_an_py310", marks=needs_py310),
], ],
scope="module",
) )
def get_client(request: pytest.FixtureRequest): def get_client(request: pytest.FixtureRequest):
clear_sqlmodel() clear_sqlmodel()

Loading…
Cancel
Save