Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/myworker/tests/test_myworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def celery_worker_cluster(
) -> CeleryWorkerCluster:
"""Add myworker worker to the workers cluster alongside the parametrize
plugin worker."""
cluster = CeleryWorkerCluster(celery_worker, myworker_worker) # type: ignore
cluster = CeleryWorkerCluster(celery_worker, myworker_worker)
yield cluster
cluster.teardown()

Expand Down
4 changes: 2 additions & 2 deletions examples/rabbitmq_management/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def celery_rabbitmq_broker(default_rabbitmq_broker: RabbitMQContainer) -> Rabbit


@pytest.fixture
def celery_broker_cluster(celery_rabbitmq_broker: RabbitMQTestBroker) -> CeleryBrokerCluster: # type: ignore
cluster = CeleryBrokerCluster(celery_rabbitmq_broker) # type: ignore
def celery_broker_cluster(celery_rabbitmq_broker: RabbitMQTestBroker) -> CeleryBrokerCluster:
cluster = CeleryBrokerCluster(celery_rabbitmq_broker)
yield cluster
cluster.teardown()
24 changes: 11 additions & 13 deletions src/pytest_celery/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from __future__ import annotations

from abc import abstractmethod
from collections.abc import Iterator

import pytest_docker_tools
Expand Down Expand Up @@ -183,11 +182,11 @@ class CeleryTestCluster:
the test.
"""

def __init__(self, *nodes: tuple[CeleryTestNode | CeleryTestContainer]) -> None:
def __init__(self, *nodes: CeleryTestNode | CeleryTestContainer) -> None:
"""Setup the base components of a CeleryTestCluster.

Args:
*nodes (tuple[CeleryTestNode | CeleryTestContainer]): Nodes to use for the cluster.
*nodes (CeleryTestNode | CeleryTestContainer): Nodes to use for the cluster.

Raises:
ValueError: At least one node is required.
Expand All @@ -200,21 +199,21 @@ def __init__(self, *nodes: tuple[CeleryTestNode | CeleryTestContainer]) -> None:
if not all(isinstance(node, (CeleryTestNode, CeleryTestContainer)) for node in nodes):
raise TypeError("All nodes must be CeleryTestNode or CeleryTestContainer")

self.nodes = nodes # type: ignore
self.nodes = nodes

@property
def nodes(self) -> tuple[CeleryTestNode]:
def nodes(self) -> tuple[CeleryTestNode, ...]:
"""Get the nodes of the cluster."""
return self._nodes

@nodes.setter
def nodes(self, nodes: tuple[CeleryTestNode | CeleryTestContainer]) -> None:
def nodes(self, nodes: tuple[CeleryTestNode | CeleryTestContainer, ...]) -> None:
"""Set the nodes of the cluster.

Args:
nodes (tuple[CeleryTestNode | CeleryTestContainer]): Nodes to use for the cluster.
nodes (tuple[CeleryTestNode | CeleryTestContainer, ...]): Nodes to use for the cluster.
"""
self._nodes = self._set_nodes(*nodes) # type: ignore
self._nodes = self._set_nodes(*nodes)

def __iter__(self) -> Iterator[CeleryTestNode]:
"""Iterate over the nodes of the cluster."""
Expand Down Expand Up @@ -242,16 +241,15 @@ def default_config(cls) -> dict:
"""Default cluster configurations if not overridden by the user."""
return {}

@abstractmethod
def _set_nodes(
self,
*nodes: tuple[CeleryTestNode | CeleryTestContainer],
*nodes: CeleryTestNode | CeleryTestContainer,
node_cls: type[CeleryTestNode] = CeleryTestNode,
) -> tuple[CeleryTestNode]:
) -> tuple[CeleryTestNode, ...]:
"""Set the nodes of the cluster.

Args:
*nodes (tuple[CeleryTestNode | CeleryTestContainer]): Nodes to use for the cluster.
*nodes (CeleryTestNode | CeleryTestContainer): Nodes to use for the cluster.
node_cls (type[CeleryTestNode], optional): Node class to use. Defaults to CeleryTestNode.

Returns:
Expand All @@ -267,7 +265,7 @@ def _set_nodes(
else node
)
for node in nodes
) # type: ignore
)

def ready(self) -> bool:
"""Waits until the cluster is ready or raise an exception if any of the
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_celery/fixtures/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def celery_backend_cluster(celery_backend: CeleryTestBackend) -> CeleryBackendCl
Returns:
CeleryBackendCluster: Single node cluster for all supported celery backends.
"""
cluster = CeleryBackendCluster(celery_backend) # type: ignore
cluster = CeleryBackendCluster(celery_backend)
yield cluster
cluster.teardown()

Expand Down
2 changes: 1 addition & 1 deletion src/pytest_celery/fixtures/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def celery_broker_cluster(celery_broker: CeleryTestBroker) -> CeleryBrokerCluste
Returns:
CeleryBrokerCluster: Single node cluster for all supported celery brokers.
"""
cluster = CeleryBrokerCluster(celery_broker) # type: ignore
cluster = CeleryBrokerCluster(celery_broker)
yield cluster
cluster.teardown()

Expand Down
2 changes: 1 addition & 1 deletion src/pytest_celery/fixtures/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def celery_worker_cluster(celery_worker: CeleryTestWorker) -> CeleryWorkerCluste
Returns:
CeleryWorkerCluster: Single node cluster for all supported celery workers.
"""
cluster = CeleryWorkerCluster(celery_worker) # type: ignore
cluster = CeleryWorkerCluster(celery_worker)
yield cluster
cluster.teardown()

Expand Down