pytest: changes fixture scopes

This commit is contained in:
Mose Müller 2024-07-30 08:36:59 +02:00
parent f91be30ad0
commit 75e355faf9
6 changed files with 11 additions and 11 deletions

View File

@ -7,7 +7,7 @@ import pytest
from pydase.client.proxy_loader import ProxyAttributeError from pydase.client.proxy_loader import ProxyAttributeError
@pytest.fixture(scope="session") @pytest.fixture(scope="module")
def pydase_client() -> Generator[pydase.Client, None, Any]: def pydase_client() -> Generator[pydase.Client, None, Any]:
class SubService(pydase.DataService): class SubService(pydase.DataService):
name = "SubService" name = "SubService"

View File

@ -6,7 +6,7 @@ import pytest
from pytest import LogCaptureFixture from pytest import LogCaptureFixture
@pytest.mark.asyncio(scope="session") @pytest.mark.asyncio(scope="function")
async def test_reconnection(caplog: LogCaptureFixture) -> None: async def test_reconnection(caplog: LogCaptureFixture) -> None:
class MyService(pydase.components.device_connection.DeviceConnection): class MyService(pydase.components.device_connection.DeviceConnection):
def __init__( def __init__(

View File

@ -35,7 +35,7 @@ def test_nested_attributes_cache_callback() -> None:
) )
@pytest.mark.asyncio(scope="session") @pytest.mark.asyncio(scope="function")
async def test_task_status_update() -> None: async def test_task_status_update() -> None:
class ServiceClass(pydase.DataService): class ServiceClass(pydase.DataService):
name = "World" name = "World"

View File

@ -10,7 +10,7 @@ from pytest import LogCaptureFixture
logger = logging.getLogger("pydase") logger = logging.getLogger("pydase")
@pytest.mark.asyncio(scope="session") @pytest.mark.asyncio(scope="function")
async def test_autostart_task_callback(caplog: LogCaptureFixture) -> None: async def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
class MyService(pydase.DataService): class MyService(pydase.DataService):
def __init__(self) -> None: def __init__(self) -> None:
@ -36,7 +36,7 @@ async def test_autostart_task_callback(caplog: LogCaptureFixture) -> None:
assert "'my_other_task' changed to 'TaskStatus.RUNNING'" in caplog.text assert "'my_other_task' changed to 'TaskStatus.RUNNING'" in caplog.text
@pytest.mark.asyncio(scope="session") @pytest.mark.asyncio(scope="function")
async def test_DataService_subclass_autostart_task_callback( async def test_DataService_subclass_autostart_task_callback(
caplog: LogCaptureFixture, caplog: LogCaptureFixture,
) -> None: ) -> None:
@ -66,7 +66,7 @@ async def test_DataService_subclass_autostart_task_callback(
assert "'sub_service.my_other_task' changed to 'TaskStatus.RUNNING'" in caplog.text assert "'sub_service.my_other_task' changed to 'TaskStatus.RUNNING'" in caplog.text
@pytest.mark.asyncio(scope="session") @pytest.mark.asyncio(scope="function")
async def test_DataService_subclass_list_autostart_task_callback( async def test_DataService_subclass_list_autostart_task_callback(
caplog: LogCaptureFixture, caplog: LogCaptureFixture,
) -> None: ) -> None:
@ -108,7 +108,7 @@ async def test_DataService_subclass_list_autostart_task_callback(
) )
@pytest.mark.asyncio(scope="session") @pytest.mark.asyncio(scope="function")
async def test_start_and_stop_task_methods(caplog: LogCaptureFixture) -> None: async def test_start_and_stop_task_methods(caplog: LogCaptureFixture) -> None:
class MyService(pydase.DataService): class MyService(pydase.DataService):
def __init__(self) -> None: def __init__(self) -> None:

View File

@ -8,7 +8,7 @@ import pydase
import pytest import pytest
@pytest.fixture(scope="session") @pytest.fixture(scope="module")
def pydase_server() -> Generator[None, None, None]: def pydase_server() -> Generator[None, None, None]:
class SubService(pydase.DataService): class SubService(pydase.DataService):
name = "SubService" name = "SubService"
@ -103,7 +103,7 @@ def pydase_server() -> Generator[None, None, None]:
), ),
], ],
) )
@pytest.mark.asyncio @pytest.mark.asyncio(scope="module")
async def test_get_value( async def test_get_value(
access_path: str, access_path: str,
expected: dict[str, Any], expected: dict[str, Any],
@ -171,7 +171,7 @@ async def test_get_value(
), ),
], ],
) )
@pytest.mark.asyncio @pytest.mark.asyncio(scope="module")
async def test_update_value( async def test_update_value(
access_path: str, access_path: str,
new_value: dict[str, Any], new_value: dict[str, Any],

View File

@ -207,7 +207,7 @@ def test_ColouredEnum_serialize() -> None:
} }
@pytest.mark.asyncio(scope="session") @pytest.mark.asyncio(scope="module")
async def test_method_serialization() -> None: async def test_method_serialization() -> None:
class ClassWithMethod(pydase.DataService): class ClassWithMethod(pydase.DataService):
def some_method(self) -> str: def some_method(self) -> str: