MCPcopy Index your code
hub / github.com/pyinvoke/invoke / start

Method start

tests/_util.py:119–142  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

117 self.start()
118
119 def start(self):
120 # Start patchin'
121 self.popen = patch("invoke.runners.Popen")
122 Popen = self.popen.start()
123 self.read = patch("os.read")
124 read = self.read.start()
125 self.sys_stdin = patch("sys.stdin", new_callable=BytesIO)
126 sys_stdin = self.sys_stdin.start()
127 # Setup mocks
128 process = Popen.return_value
129 process.returncode = self.exit
130 process.stdout.fileno.return_value = 1
131 process.stderr.fileno.return_value = 2
132 # If requested, mock isatty to fake out pty detection
133 if self.isatty is not None:
134 sys_stdin.isatty = Mock(return_value=self.isatty)
135
136 def fakeread(fileno, count):
137 fd = {1: self.out_file, 2: self.err_file}[fileno]
138 return fd.read(count)
139
140 read.side_effect = fakeread
141 # Return the Popen mock as it's sometimes wanted inside tests
142 return Popen
143
144 def stop(self):
145 self.popen.stop()

Callers 2

__init__Method · 0.95
wrapperFunction · 0.95

Calls 1

startMethod · 0.45

Tested by

no test coverage detected