module documentation

Tools for automated testing of twisted.pair-based applications.

Class MemoryIOSystem An in-memory implementation of basic I/O primitives, useful in the context of unit testing as a drop-in replacement for parts of the os module.
Class Tunnel An in-memory implementation of a tun or tap device.
Class _FakePort A socket-like object which can be used to read UDP datagrams from tunnel-like file descriptors managed by a MemoryIOSystem.
Function _ethernet Construct an ethernet frame.
Function _H Pack an integer into a network-order two-byte string.
Function _ip Construct an IP datagram with the given source, destination, and application payload.
Function _privileged Wrap a MemoryIOSystem method with permission-checking logic. The returned function will check self.permissions and raise IOError with errno.EPERM if the function name is not listed as an available permission.
Function _udp Construct a UDP datagram with the given source, destination, and application payload.
Constant _PI_SIZE Undocumented
Variable _IPv4 Undocumented
def _ethernet(src, dst, protocol, payload): (source)

Construct an ethernet frame.

Parameters
src:bytesThe source ethernet address, encoded.
dst:bytesThe destination ethernet address, encoded.
protocol:intThe protocol number of the payload of this datagram.
payload:bytesThe content of the ethernet frame (such as an IP datagram).
Returns
bytesThe full ethernet frame.
def _H(n): (source)

Pack an integer into a network-order two-byte string.

Parameters
nThe integer to pack. Only values that fit into 16 bits are supported.
Returns
bytesThe packed representation of the integer.
def _ip(src, dst, payload): (source)

Construct an IP datagram with the given source, destination, and application payload.

Parameters
src:bytesThe source IPv4 address as a dotted-quad string.
dst:bytesThe destination IPv4 address as a dotted-quad string.
payload:bytesThe content of the IP datagram (such as a UDP datagram).
Returns
bytesAn IP datagram header and payload.
def _privileged(original): (source)

Wrap a MemoryIOSystem method with permission-checking logic. The returned function will check self.permissions and raise IOError with errno.EPERM if the function name is not listed as an available permission.

Parameters
originalThe MemoryIOSystem instance to wrap.
Returns
A wrapper around original that applies permission checks.
def _udp(src, dst, payload): (source)

Construct a UDP datagram with the given source, destination, and application payload.

Parameters
src:intThe source port number.
dst:intThe destination port number.
payload:bytesThe content of the UDP datagram.
Returns
bytesA UDP datagram header and payload.
_PI_SIZE: int = (source)

Undocumented

Value
4

Undocumented