mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-14 18:58:10 +08:00
Upgrade pytest-asyncio usage
This commit is contained in:
@ -126,13 +126,6 @@ class UserManagerMock(BaseTestUserManager[models.UP]):
|
||||
_update: MagicMock
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def event_loop():
|
||||
loop = asyncio.get_event_loop()
|
||||
yield loop
|
||||
loop.close()
|
||||
|
||||
|
||||
AsyncMethodMocker = Callable[..., MagicMock]
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ from typing import AsyncGenerator, Generic, List, Optional, Sequence
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import Depends, FastAPI, Request, status
|
||||
from fastapi.security.base import SecurityBase
|
||||
|
||||
@ -66,8 +67,7 @@ def get_backend_user(user: UserModel):
|
||||
return _get_backend_user
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
def get_test_auth_client(get_user_manager, get_test_client):
|
||||
async def _get_test_auth_client(
|
||||
backends: List[AuthenticationBackend],
|
||||
|
@ -2,14 +2,14 @@ from typing import AsyncGenerator, Optional
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import Depends, FastAPI, status
|
||||
|
||||
from fastapi_users import FastAPIUsers, schemas
|
||||
from tests.conftest import IDType, User, UserCreate, UserModel, UserUpdate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
async def test_app_client(
|
||||
secret,
|
||||
get_user_manager,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import FastAPI, status
|
||||
|
||||
from fastapi_users.fastapi_users import FastAPIUsers
|
||||
@ -28,8 +29,7 @@ def test_app(
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
async def test_app_client(test_app, get_test_client):
|
||||
async for client in get_test_client(test_app):
|
||||
yield client
|
||||
|
@ -2,6 +2,7 @@ from typing import Any, AsyncGenerator, Dict, Tuple, cast
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import FastAPI, status
|
||||
|
||||
from fastapi_users.authentication import Authenticator
|
||||
@ -39,10 +40,9 @@ def app_factory(get_user_manager, mock_authentication):
|
||||
return _app_factory
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
@pytest_asyncio.fixture(
|
||||
params=[True, False], ids=["required_verification", "not_required_verification"]
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_client(
|
||||
request, get_test_client, app_factory
|
||||
) -> AsyncGenerator[Tuple[httpx.AsyncClient, bool], None]:
|
||||
|
@ -2,6 +2,7 @@ from typing import Any, Dict, cast
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import FastAPI, status
|
||||
from httpx_oauth.oauth2 import BaseOAuth2, OAuth2
|
||||
|
||||
@ -69,15 +70,13 @@ def test_app_requires_verification(app_factory):
|
||||
return app_factory(requires_verification=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
async def test_app_client(test_app, get_test_client):
|
||||
async for client in get_test_client(test_app):
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
async def test_app_client_redirect_url(test_app_redirect_url, get_test_client):
|
||||
async for client in get_test_client(test_app_redirect_url):
|
||||
yield client
|
||||
|
@ -2,14 +2,14 @@ from typing import Any, AsyncGenerator, Dict, cast
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import FastAPI, status
|
||||
|
||||
from fastapi_users.router import ErrorCode, get_register_router
|
||||
from tests.conftest import User, UserCreate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
async def test_app_client(
|
||||
get_user_manager, get_test_client
|
||||
) -> AsyncGenerator[httpx.AsyncClient, None]:
|
||||
|
@ -2,6 +2,7 @@ from typing import Any, AsyncGenerator, Dict, cast
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import FastAPI, status
|
||||
|
||||
from fastapi_users.exceptions import (
|
||||
@ -14,8 +15,7 @@ from fastapi_users.router import ErrorCode, get_reset_password_router
|
||||
from tests.conftest import AsyncMethodMocker, UserManagerMock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
async def test_app_client(
|
||||
get_user_manager, get_test_client
|
||||
) -> AsyncGenerator[httpx.AsyncClient, None]:
|
||||
|
@ -2,6 +2,7 @@ from typing import Any, AsyncGenerator, Dict, Tuple, cast
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import FastAPI, status
|
||||
|
||||
from fastapi_users.authentication import Authenticator
|
||||
@ -33,10 +34,9 @@ def app_factory(get_user_manager, mock_authentication):
|
||||
return _app_factory
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
@pytest_asyncio.fixture(
|
||||
params=[True, False], ids=["required_verification", "not_required_verification"]
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_app_client(
|
||||
request, get_test_client, app_factory
|
||||
) -> AsyncGenerator[Tuple[httpx.AsyncClient, bool], None]:
|
||||
|
@ -2,6 +2,7 @@ from typing import Any, AsyncGenerator, Dict, cast
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi import FastAPI, status
|
||||
|
||||
from fastapi_users.exceptions import (
|
||||
@ -14,8 +15,7 @@ from fastapi_users.router import ErrorCode, get_verify_router
|
||||
from tests.conftest import AsyncMethodMocker, User, UserManagerMock, UserModel
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.mark.asyncio
|
||||
@pytest_asyncio.fixture
|
||||
async def test_app_client(
|
||||
get_user_manager,
|
||||
get_test_client,
|
||||
|
Reference in New Issue
Block a user