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

Class Tunnel An in-memory implementation of a tun or tap device.
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.
Function _H Pack an integer into a network-order two-byte string.
Function _ethernet Construct an ethernet frame.
Function _ip Construct an IP datagram with the given source, destination, and application payload.
Function _udp Construct a UDP datagram with the given source, destination, and application payload.
Function _privileged No summary
Class _FakePort A socket-like object which can be used to read UDP datagrams from tunnel-like file descriptors managed by a MemoryIOSystem.
def _H(n): (source)

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

ParametersnThe integer to pack. Only values that fit into 16 bits are supported.
ReturnsThe packed representation of the integer. (type: bytes)
def _ethernet(src, dst, protocol, payload): (source)

Construct an ethernet frame.

ParameterssrcThe source ethernet address, encoded. (type: bytes)
dstThe destination ethernet address, encoded. (type: bytes)
protocolThe protocol number of the payload of this datagram. (type: int)
payloadThe content of the ethernet frame (such as an IP datagram). (type: bytes)
ReturnsThe full ethernet frame. (type: bytes)
def _ip(src, dst, payload): (source)

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

ParameterssrcThe source IPv4 address as a dotted-quad string. (type: bytes)
dstThe destination IPv4 address as a dotted-quad string. (type: bytes)
payloadThe content of the IP datagram (such as a UDP datagram). (type: bytes)
ReturnsAn IP datagram header and payload. (type: bytes)
def _udp(src, dst, payload): (source)

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

ParameterssrcThe source port number. (type: int)
dstThe destination port number. (type: int)
payloadThe content of the UDP datagram. (type: bytes)
ReturnsA UDP datagram header and payload. (type: bytes)
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.

ParametersoriginalThe MemoryIOSystem instance to wrap.
ReturnsA wrapper around original that applies permission checks.
API Documentation for Twisted, generated by pydoctor at 2018-04-29 21:01:12.