connection_error¶
Signature¶
faultcore.connection_error(*, kind: str, prob: str = "100%")
Purpose¶
Injects explicit transport connection errors.
Defaults and validation¶
kindmust be one ofreset,refused,unreachable.probuses packet loss parser (%orppm).
Unit test example (pytest)¶
import faultcore
import pytest
def test_client_handles_refused_connection() -> None:
@faultcore.connection_error(kind="refused", prob="40%")
def connect() -> None:
raise ConnectionRefusedError("simulated")
with pytest.raises(ConnectionRefusedError):
connect()
Integration example (real network path)¶
Transport integration coverage:
tests/integration/test_targets_hostname_transport.pyEnd-to-end execution guidance:
docs/testing_and_examples.md