Table of Contents

Module: mockets ./src/peak/util/mockets.py

Mock Sockets and related types, used for testing socket code

Mockets currently only implement AF_INET and SOCK_STREAM. They also don't support the getsockopt(), setsockopt(), recvfrom(), sendto(), makefile(), or shutdown() operations of real sockets, or the flags argument to send() or recv(). They don't support out of band data, exception conditions, or anything else whose implementation is too platform or protocol-dependent.

Some of these limitations may be lifted later, e.g. SOCK_DGRAM, recvfrom(), and sendto(), if/when we need to test things that use them. We should probably also at least support storing and retrieving options via the getsockopt() and setsockopt() methods, so that tests can verify whether code is setting options that should be set.

Note that real sockets' shutdown() and makefile() behavior is extremely platform-dependent, to the point that we should simply avoid them altogether if possible. In particular, shutdown() on Windows seems to be seriously broken, and makefile() on Windows, RISCOS, and BeOS is emulated with a crude simulation of a file that doesn't support most real file operations.

TODO

  • Integrate into peak.events.tests for testing un-Twisted selector

Imported modules   
import errno
from weakref import WeakValueDictionary
Classes   

MocketType

Emulation of a socket object

SocketSystem

A collection of socket objects that can connect to each other

WouldBlock

Socket is in blocking mode, and operation would block


Table of Contents

This document was automatically generated on Mon Nov 11 01:11:04 2024 by HappyDoc version 2.1