cheroot.test.test_makefile module#

Tests for cheroot.makefile.

class cheroot.test.test_makefile.MockRawIO#

Bases: object

A mock io.RawIOBase object for use as the raw layer of a BufferedWriter.

close()#

Emulate close.

property closed#

Emulate the required closed property.

writable()#

Indicate that the raw stream supports writing.

write(message)#

Emulate io.RawIOBase write.

class cheroot.test.test_makefile.MockSocket#

Bases: object

A mock socket for emulating buffered I/O.

_decref_socketios()#

Emulate socket I/O reference decrement.

recv(size)#

Simulate recv for Python 2.

recv_into(buf)#

Simulate recv_into for Python 3.

send(val)#

Simulate a send.

cheroot.test.test_makefile._make_blocking_io_error()#

Create a BlockingIOError with characters_written set.

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_error_handling(exc, reraises, mocker)#

Test that expected socket errors are swallowed and others re-raised.

cheroot.test.test_makefile.test_close_is_idempotent()#

Test that double close() does not error out.

cheroot.test.test_makefile.test_close_when_raw_already_closed()#

Test that close() is safe when the raw buffer was closed externally.

Simulates a race where the OS or another thread closed the raw socket before BufferedWriter.close() is called.

cheroot.test.test_makefile.test_flush_unlocked_write_outcomes(write_kwargs, expected_buf_len, mocker)#

Test that _flush_unlocked handles various write() outcomes.