Bases: Generic[Broker]
A class to represent a test broker.
Source code in faststream/testing/broker.py
| def __init__(
self,
broker: Broker,
with_real: bool = False,
connect_only: Optional[bool] = None,
) -> None:
self.with_real = with_real
self.broker = broker
if connect_only is None:
try:
connect_only = is_contains_context_name(
self.__class__.__name__,
TestApp.__name__,
)
except Exception: # pragma: no cover
warnings.warn(
(
"\nError `{e!r}` occurred at `{self.__class__.__name__}` AST parsing."
"\n`connect_only` is set to `False` by default."
),
category=RuntimeWarning,
stacklevel=1,
)
connect_only = False
self.connect_only = connect_only
self._fake_subscribers: List[SubscriberProto[Any]] = []
|
with_real instance-attribute
broker instance-attribute
connect_only instance-attribute
create_publisher_fake_subscriber abstractmethod
staticmethod
create_publisher_fake_subscriber(broker, publisher)
Source code in faststream/testing/broker.py
| @staticmethod
@abstractmethod
def create_publisher_fake_subscriber(
broker: Broker, publisher: Any
) -> Tuple["SubscriberProto[Any]", bool]:
raise NotImplementedError
|