class documentation
class MockOS: (source)
Method | __init__ |
Initialize data structures. |
Method | chdir |
Override os.chdir. Save the action. |
Method | close |
Fake os.close, saving the closed fd in self.closed. |
Method | dup2 |
Fake os.dup2. Do nothing. |
Method | execvpe |
Fake os.execvpe. Save the action, and raise an error if self.raiseExec is set. |
Method | expanduser |
Mock os.path.expanduser. |
Method | fdopen |
Fake os.fdopen. Return a file-like object whose content can be tested later via self.fdio. |
Method | fork |
Fake os.fork. Save the action in self.actions, and return 0 if self.child is set, or a dumb number. |
Method | fstat |
Fake os.fstat. Return a os.stat_result filled with garbage. |
Method | getegid |
Mock os.getegid, returning self.egid instead. |
Method | geteuid |
Mock os.geteuid, returning self.euid instead. |
Method | getfilesystemencoding |
Return a fixed filesystem encoding. |
Method | getgid |
Override os.getgid. Return a dumb number. |
Method | getpid |
Return a fixed PID value. |
Method | getpwnam |
Mock pwd.getpwnam. |
Method | getuid |
Override os.getuid. Return a dumb number. |
Method | ioctl |
Override fcntl.ioctl. Do nothing. |
Method | kill |
Override os.kill: save the action and raise self.raiseKill if specified. |
Method | listdir |
Override os.listdir, returning fake contents of '/dev/fd' |
Method | open |
Fake os.open. Return a non fd number to be sure it's not used elsewhere. |
Method | openpty |
Override pty.openpty, returning fake file descriptors. |
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 | read |
Fake os.read: save action, and return readData content. |
Method | setegid |
Mock os.setegid, store result. |
Method | seteuid |
Mock os.seteuid, store result. |
Method | setgid |
Override os.setgid. Do nothing. |
Method | set |
Override fdesc.setNonBlocking. Do nothing. |
Method | setregid |
Override os.setregid. Do nothing. |
Method | setreuid |
Override os.setreuid. Save the action. |
Method | setsid |
Fake os.setsid. Save action. |
Method | settrace |
Override sys.settrace to keep coverage working. |
Method | setuid |
Override os.setuid. Do nothing. |
Method | switch |
Override util.switchUID . Save the action. |
Method | ttyname |
Fake os.ttyname. Return a dumb string. |
Method | umask |
Override os.umask. Save the action. |
Method | unlink |
Override os.unlink. Save the action. |
Method | waitpid |
Override os.waitpid. Return values meaning that the child process has exited, save executed action. |
Method | write |
Fake os.write. Save action. |
Instance Variable | actions |
hold names of some actions executed by the object, in order of execution. |
Instance Variable | child |
whether fork return for the child or the parent. |
Instance Variable | closed |
keep track of the file descriptor closed. |
Instance Variable | egid |
the gid returned by the fake os.getegid |
Instance Variable | euid |
the uid returned by the fake os.geteuid |
Instance Variable | exited |
set to True when _exit is called. |
Instance Variable | fdio |
fake file object returned by calls to fdopen. |
Instance Variable | O |
dumb value faking os.O_NOCTTY. |
Instance Variable | O |
dumb value faking os.O_RDWR. |
Instance Variable | path |
the path returned by os.path.expanduser. |
Instance Variable | pipe |
count the number of time that os.pipe has been called. |
Instance Variable | raise |
if set, subsequent calls to execvpe will raise an error. |
Instance Variable | raise |
if not None , subsequent calls to fork will raise this object. |
Instance Variable | raise |
if set, subsequent call to kill will raise the error specified. |
Instance Variable | raise |
if set, subsequent calls to waitpid will raise the error specified. |
Instance Variable | read |
data returned by os.read. |
Instance Variable | setegid |
stored results of os.setegid calls. |
Instance Variable | seteuid |
stored results of os.seteuid calls. |
Instance Variable | wait |
if set, subsequent calls to waitpid will return it. |
Instance Variable | WEXITSTATUS |
Undocumented |
Instance Variable | WIFEXITED |
Undocumented |
Instance Variable | WNOHANG |
dumb value faking os.WNOHANG. |
Method | _exit |
Fake os._exit. Save the action, set the self.exited flag, and raise SystemError. |
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.
Fake os.read: save action, and return readData content.
Parameters | |
fd | The file descriptor to read. |
size | The maximum number of bytes to read. |
Returns | |
A fixed bytes buffer. |