module documentation
Assorted functionality which is commonly useful when writing unit tests.
Class |
|
AccumulatingProtocol is an IProtocol implementation which collects the data delivered to it and can fire a Deferred when it is connected or disconnected. |
Class |
|
ILogObserver That stores its events in a list for later inspection. This class is similar to LimitedHistoryLogObserver save that the internal buffer is public and intended for external inspection. The observer implements the sequence protocol to ease iteration of the events. |
Class |
|
Undocumented |
Class |
|
Undocumented |
Class |
|
A fake reactor to be used in tests. This reactor doesn't actually do much that's useful yet. It accepts TCP connection setup attempts, but they will never succeed. |
Class |
|
Undocumented |
Class |
|
A pull producer which writes 10 times only. |
Class |
|
A fake reactor to be used in tests. It accepts TCP connection setup attempts, but they will fail. |
Class |
|
A BytesIO that can't be closed. |
Class |
|
A transport implementation which buffers data in memory and keeps track of its other state without providing any behavior. |
Class |
|
A StringTransport which on disconnection will trigger the connection lost on the attached protocol. |
Function | wait |
Take a list of disconnecting protocols, callback a Deferred when they're all done. |
Class | _ |
A fake IConnector that allows us to inspect if it has been told to stop connecting. |
Class | _ |
A fake IListeningPort to be used in tests. |
Function | _benchmark |
Decorator for running a benchmark tests that loops the reactor. |
Function | _run |
(re)Start a reactor that might have been previously started. |
Function | _stop |
Stop the reactor and allow it to be re-started later. |
Constant | _P |
Undocumented |
Type Variable | _T |
Undocumented |
Take a list of disconnecting protocols, callback a Deferred
when they're all done.
This is a hack to make some older tests less flaky, as ITransport.loseConnection
is not atomic on all reactors (for example, the CoreFoundation, which sometimes takes a reactor turn for CFSocket to realise). New tests should either not use real sockets in testing, or take the advice in https://jml.io/pages/how-to-disconnect-in-twisted-really.html to heart.
Parameters | |
reactor:IReactorTime | The reactor to schedule the checks on. |
protocols:A list of IProtocol s. | The protocols to wait for disconnecting. |
def _benchmarkWithReactor(test_target:
Callable[ [], Union[ Coroutine[ Deferred[ Any], Any, _T], Generator[ Deferred[ Any], Any, _T], Deferred[ _T]]]
) -> Callable[ [ Any], None]
:
(source)
¶
Decorator for running a benchmark tests that loops the reactor.
This is designed to decorate test method executed using pytest and pytest-benchmark.