The mock OS: overwrite os, fcntl and {sys} functions with fake ones.

Instance Variable exited set to True when _exit is called. (type: bool)
Instance Variable O_RDWR dumb value faking os.O_RDWR. (type: int)
Instance Variable O_NOCTTY dumb value faking os.O_NOCTTY. (type: int)
Instance Variable WNOHANG dumb value faking os.WNOHANG. (type: int)
Instance Variable raiseFork if not None, subsequent calls to fork will raise this object. (type: None or Exception)
Instance Variable raiseExec if set, subsequent calls to execvpe will raise an error. (type: bool)
Instance Variable fdio fake file object returned by calls to fdopen. (type: BytesIO or BytesIO)
Instance Variable actions hold names of some actions executed by the object, in order of execution. (type: list of str)
Instance Variable closed keep track of the file descriptor closed. (type: list of int)
Instance Variable child whether fork return for the child or the parent. (type: bool)
Instance Variable pipeCount count the number of time that os.pipe has been called. (type: int)
Instance Variable raiseWaitPid if set, subsequent calls to waitpid will raise the error specified. (type: None or a class)
Instance Variable waitChild if set, subsequent calls to waitpid will return it. (type: None or a tuple)
Instance Variable euid the uid returned by the fake os.geteuid (type: int)
Instance Variable egid the gid returned by the fake os.getegid (type: int)
Instance Variable seteuidCalls stored results of os.seteuid calls. (type: list)
Instance Variable setegidCalls stored results of os.setegid calls. (type: list)
Instance Variable path the path returned by os.path.expanduser. (type: str)
Instance Variable raiseKill if set, subsequent call to kill will raise the error specified. (type: None or an exception instance.)
Instance Variable readData data returned by os.read. (type: str)
Method __init__ Initialize data structures.
Method open Fake os.open. Return a non fd number to be sure it's not used elsewhere.
Method fstat Fake os.fstat. Return a os.stat_result filled with garbage.
Method fdopen Fake os.fdopen. Return a file-like object whose content can be tested later via self.fdio.
Method setsid Fake os.setsid. Save action.
Method fork Fake os.fork. Save the action in self.actions, and return 0 if self.child is set, or a dumb number.
Method close Fake os.close, saving the closed fd in self.closed.
Method dup2 Fake os.dup2. Do nothing.
Method write Fake os.write. Save action.
Method read Fake os.read: save action, and return readData content.
Method execvpe Fake os.execvpe. Save the action, and raise an error if self.raiseExec is set.
Method pipe Fake os.pipe. Return non fd numbers to be sure it's not used elsewhere, and increment self.pipeCount. This is used to uniquify the result.
Method ttyname Fake os.ttyname. Return a dumb string.
Method ioctl Override fcntl.ioctl. Do nothing.
Method setNonBlocking Override fdesc.setNonBlocking. Do nothing.
Method waitpid Override os.waitpid. Return values meaning that the child process has exited, save executed action.
Method settrace Override sys.settrace to keep coverage working.
Method getgid Override os.getgid. Return a dumb number.
Method getuid Override os.getuid. Return a dumb number.
Method setuid Override os.setuid. Do nothing.
Method setgid Override os.setgid. Do nothing.
Method setregid Override os.setregid. Do nothing.
Method setreuid Override os.setreuid. Save the action.
Method switchUID Override util.switchUID. Save the action.
Method openpty Override pty.openpty, returning fake file descriptors.
Method chdir Override os.chdir. Save the action.
Method geteuid Mock os.geteuid, returning self.euid instead.
Method getegid Mock os.getegid, returning self.egid instead.
Method seteuid Mock os.seteuid, store result.
Method setegid Mock os.setegid, store result.
Method expanduser Mock os.path.expanduser.
Method getpwnam Mock pwd.getpwnam.
Method listdir Override os.listdir, returning fake contents of '/dev/fd'
Method kill Override os.kill: save the action and raise self.raiseKill if specified.
Method unlink Override os.unlink. Save the action.
Method umask Override os.umask. Save the action.
Method getpid Return a fixed PID value.
Method getfilesystemencoding Return a fixed filesystem encoding.
Method _exit Fake os._exit. Save the action, set the self.exited flag, and raise SystemError.
exited =
set to True when _exit is called. (type: bool)
O_RDWR =
dumb value faking os.O_RDWR. (type: int)
O_NOCTTY =
dumb value faking os.O_NOCTTY. (type: int)
WNOHANG =
dumb value faking os.WNOHANG. (type: int)
raiseFork =
if not None, subsequent calls to fork will raise this object. (type: None or Exception)
raiseExec =
if set, subsequent calls to execvpe will raise an error. (type: bool)
fdio =
fake file object returned by calls to fdopen. (type: BytesIO or BytesIO)
actions =
hold names of some actions executed by the object, in order of execution. (type: list of str)
closed =
keep track of the file descriptor closed. (type: list of int)
child =
whether fork return for the child or the parent. (type: bool)
pipeCount =
count the number of time that os.pipe has been called. (type: int)
raiseWaitPid =
if set, subsequent calls to waitpid will raise the error specified. (type: None or a class)
waitChild =
if set, subsequent calls to waitpid will return it. (type: None or a tuple)
euid =
the uid returned by the fake os.geteuid (type: int)
egid =
the gid returned by the fake os.getegid (type: int)
seteuidCalls =
stored results of os.seteuid calls. (type: list)
setegidCalls =
stored results of os.setegid calls. (type: list)
path =
the path returned by os.path.expanduser. (type: str)
raiseKill =
if set, subsequent call to kill will raise the error specified. (type: None or an exception instance.)
readData =
data returned by os.read. (type: str)
def __init__(self):

Initialize data structures.

def open(self, dev, flags):

Fake os.open. Return a non fd number to be sure it's not used elsewhere.

def fstat(self, fd):

Fake os.fstat. Return a os.stat_result filled with garbage.

def fdopen(self, fd, flag):

Fake os.fdopen. Return a file-like object whose content can be tested later via self.fdio.

def setsid(self):

Fake os.setsid. Save action.

def fork(self):

Fake os.fork. Save the action in self.actions, and return 0 if self.child is set, or a dumb number.

def close(self, fd):

Fake os.close, saving the closed fd in self.closed.

def dup2(self, fd1, fd2):

Fake os.dup2. Do nothing.

def write(self, fd, data):

Fake os.write. Save action.

def read(self, fd, size):

Fake os.read: save action, and return readData content.

ParametersfdThe file descriptor to read.
sizeThe maximum number of bytes to read.
ReturnsA fixed bytes buffer.
def execvpe(self, command, args, env):

Fake os.execvpe. Save the action, and raise an error if self.raiseExec is set.

def pipe(self):

Fake os.pipe. Return non fd numbers to be sure it's not used elsewhere, and increment self.pipeCount. This is used to uniquify the result.

def ttyname(self, fd):

Fake os.ttyname. Return a dumb string.

def _exit(self, code):

Fake os._exit. Save the action, set the self.exited flag, and raise SystemError.

def ioctl(self, fd, flags, arg):

Override fcntl.ioctl. Do nothing.

def setNonBlocking(self, fd):

Override fdesc.setNonBlocking. Do nothing.

def waitpid(self, pid, options):

Override os.waitpid. Return values meaning that the child process has exited, save executed action.

def settrace(self, arg):

Override sys.settrace to keep coverage working.

def getgid(self):

Override os.getgid. Return a dumb number.

def getuid(self):

Override os.getuid. Return a dumb number.

def setuid(self, val):

Override os.setuid. Do nothing.

def setgid(self, val):

Override os.setgid. Do nothing.

def setregid(self, val1, val2):

Override os.setregid. Do nothing.

def setreuid(self, val1, val2):

Override os.setreuid. Save the action.

def switchUID(self, uid, gid):

Override util.switchUID. Save the action.

def openpty(self):

Override pty.openpty, returning fake file descriptors.

def chdir(self, path):

Override os.chdir. Save the action.

ParameterspathThe path to change the current directory to.
def geteuid(self):

Mock os.geteuid, returning self.euid instead.

def getegid(self):

Mock os.getegid, returning self.egid instead.

def seteuid(self, egid):

Mock os.seteuid, store result.

def setegid(self, egid):

Mock os.setegid, store result.

def expanduser(self, path):

Mock os.path.expanduser.

def getpwnam(self, user):

Mock pwd.getpwnam.

def listdir(self, path):

Override os.listdir, returning fake contents of '/dev/fd'

def kill(self, pid, signalID):

Override os.kill: save the action and raise self.raiseKill if specified.

def unlink(self, filename):

Override os.unlink. Save the action.

ParametersfilenameThe file name to remove.
def umask(self, mask):

Override os.umask. Save the action.

ParametersmaskThe new file mode creation mask.
def getpid(self):

Return a fixed PID value.

ReturnsA fixed value.
def getfilesystemencoding(self):

Return a fixed filesystem encoding.

ReturnsA fixed value of "utf8".
API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.