twisted.pair.testing
module documentationtwisted.pair
View Source
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 . |
Pack an integer into a network-order two-byte string.
Parameters | n | The integer to pack. Only values that fit into 16 bits are supported. |
Returns | The packed representation of the integer. (type: bytes ) |
Construct an ethernet frame.
Parameters | src | The source ethernet address, encoded. (type: bytes ) |
dst | The destination ethernet address, encoded. (type: bytes ) | |
protocol | The protocol number of the payload of this datagram. (type: int ) | |
payload | The content of the ethernet frame (such as an IP datagram). (type: bytes ) | |
Returns | The full ethernet frame. (type: bytes ) |
Construct an IP datagram with the given source, destination, and application payload.
Parameters | src | The source IPv4 address as a dotted-quad string. (type: bytes ) |
dst | The destination IPv4 address as a dotted-quad string. (type: bytes ) | |
payload | The content of the IP datagram (such as a UDP datagram). (type: bytes ) | |
Returns | An IP datagram header and payload. (type: bytes ) |
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 | original | The MemoryIOSystem
instance to wrap. |
Returns | A wrapper around original that applies permission checks. |