Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`pair`.`testing`.`MemoryIOSystem``

class documentation

`class MemoryIOSystem: (source)`

Implements interfaces: `twisted.pair.tuntap._IInputOutputSystem`

View In Hierarchy

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.

Method | `__init__` | Undocumented
Method | `close` | Discard the in-memory buffer and other in-memory state for the given file descriptor.
Method | `getTunnel` | Get the `Tunnel` object associated with the given `TuntapPort`.
Method | `ioctl` | Perform some configuration change to the in-memory state for the given file descriptor.
Method | `open` | A replacement for `os.open`. This initializes state in this `MemoryIOSystem` which will be reflected in the behavior of the other file descriptor-related methods (eg `MemoryIOSystem.read`, `MemoryIOSystem.write`...
Method | `read` | Try to read some bytes out of one of the in-memory buffers which may previously have been populated by `write`.
Method | `receiveUDP` | Get a socket-like object which can be used to receive a datagram sent from the given address.
Method | `registerSpecialDevice` | Specify a class which will be used to handle I/O to a device of a particular name.
Method | `sendUDP` | Write an ethernet frame containing an ip datagram containing a udp datagram containing the given payload, addressed to the given address, to a tunnel device previously opened on this I/O system.
Method | `write` | Try to add some bytes to one of the in-memory buffers to be accessed by a later `read` call.
Constant | `O_CLOEXEC` | No summary
Constant | `O_NONBLOCK` | No summary
Constant | `O_RDWR` | No summary
Instance Variable | `permissions` | No summary
Instance Variable | `_counter` | No summary
Instance Variable | `_devices` | No summary
Instance Variable | `_openFiles` | No summary

def __init__(self): (source)

Undocumented

def close(self, fd): (source)
from `twisted.pair.tuntap._IInputOutputSystem`

Discard the in-memory buffer and other in-memory state for the given file descriptor.

See Also
`os.close`

def getTunnel(self, port): (source)

Get the `Tunnel` object associated with the given `TuntapPort`.

Parameters
port | A `TuntapPort` previously initialized using this `MemoryIOSystem`.
Returns
`Tunnel` | The tunnel object created by a prior use of `open` on this object on the tunnel special device file.

@_privileged
def ioctl(self, fd, request, args): (source)
from `twisted.pair.tuntap._IInputOutputSystem`

Perform some configuration change to the in-memory state for the given file descriptor.

See Also
`fcntl.ioctl`

@_privileged
def open(self, name, flags, mode=None): (source)
from `twisted.pair.tuntap._IInputOutputSystem`

A replacement for `os.open`. This initializes state in this `MemoryIOSystem` which will be reflected in the behavior of the other file descriptor-related methods (eg `MemoryIOSystem.read`, `MemoryIOSystem.write`, etc).

Parameters
name:`bytes` | A string giving the name of the file to open.
flags:`int` | The flags with which to open the file.
mode:`int` | The mode with which to open the file.
Returns
`int` | A file descriptor associated with the newly opened file description.
Raises
`OSError` | With `ENOSYS` if the file is not a recognized special device file.

def read(self, fd, limit): (source)
from `twisted.pair.tuntap._IInputOutputSystem`

Try to read some bytes out of one of the in-memory buffers which may previously have been populated by `write`.

See Also
`os.read`

def receiveUDP(self, fileno, host, port): (source)
from `twisted.pair.tuntap._IInputOutputSystem`

Get a socket-like object which can be used to receive a datagram sent from the given address.

Parameters
fileno:`int` | A file descriptor representing a tunnel device which the datagram will be received via.
host:`bytes` | The IPv4 address to which the datagram was sent.
port:`int` | The UDP port number to which the datagram was sent. received.
Returns
A `socket.socket`-like object which can be used to receive the specified datagram.

def registerSpecialDevice(self, name, cls): (source)

Specify a class which will be used to handle I/O to a device of a particular name.

Parameters
name:`bytes` | The filesystem path name of the device.
cls | A class (like `Tunnel`) to instantiated whenever this device is opened.

def sendUDP(self, datagram, address): (source)
from `twisted.pair.tuntap._IInputOutputSystem`

Write an ethernet frame containing an ip datagram containing a udp datagram containing the given payload, addressed to the given address, to a tunnel device previously opened on this I/O system.

Parameters
datagram:`bytes` | A UDP datagram payload to send.
address:`tuple` of (`bytes`, `int`) | The destination to which to send the datagram.
Returns
`tuple` of (`bytes`, `int`) | A two-tuple giving the address from which gives the address from which the datagram was sent.

def write(self, fd, data): (source)
from `twisted.pair.tuntap._IInputOutputSystem`

Try to add some bytes to one of the in-memory buffers to be accessed by a later `read` call.

See Also
`os.write`

O_CLOEXEC = (source)
from `twisted.pair.tuntap._IInputOutputSystem`

See Also
`os.O_CLOEXEC`

Value

    1<<2

O_NONBLOCK = (source)
from `twisted.pair.tuntap._IInputOutputSystem`

See Also
`os.O_NONBLOCK`

Value

    1<<1

O_RDWR = (source)
from `twisted.pair.tuntap._IInputOutputSystem`

See Also
`os.O_RDWR`

Value

    1<<0

permissions: `set[str]` = (source)
_counter: `int` = (source)
_devices: `dict` = (source)
_openFiles: `dict` = (source)