cheroot.test.test_makefile module¶
Tests for cheroot.makefile.
- class cheroot.test.test_makefile.DeadSocket(exc=None)¶
Bases:
MockSocketA mock socket whose file descriptor is already invalid.
Simulates a connection that was torn down (e.g. an aborted TLS session) so that any attempt to send raises
OSError.- send(val)¶
Fail as if the underlying descriptor is gone.
- class cheroot.test.test_makefile.MockSocket¶
Bases:
objectA mock socket.
- _decref_socketios()¶
Emulate socket I/O reference decrement.
- recv(size)¶
Simulate
recvfor Python 2.
- recv_into(buf)¶
Simulate
recv_intofor Python 3.
- send(val)¶
Simulate a send.
- cheroot.test.test_makefile.test_bytes_read()¶
Reader should capture bytes read.
- cheroot.test.test_makefile.test_bytes_written()¶
Writer should capture bytes written.
- cheroot.test.test_makefile.test_close_on_dead_socket_is_swallowed()¶
Closing a writer with a dead socket must not raise.
closeperforms an implicit flush; on a dead descriptor this is the exact path exercised by the finalizerIOBase.__del__.
- cheroot.test.test_makefile.test_flush_on_dead_socket_is_swallowed(exc)¶
Flushing to a dead socket must not raise.
A buffered write flushed after the socket’s descriptor became invalid should not propagate the error, otherwise it taints the worker thread teardown path and can wedge the server over time.