| 186 | assert_(o == 'Heipa') |
| 187 | |
| 188 | def check_execute_in(self, **kws): |
| 189 | with tempdir() as tmpdir: |
| 190 | fn = "file" |
| 191 | tmpfile = os.path.join(tmpdir, fn) |
| 192 | with open(tmpfile, 'w') as f: |
| 193 | f.write('Hello') |
| 194 | |
| 195 | s, o = exec_command.exec_command( |
| 196 | '"%s" -c "f = open(\'%s\', \'r\'); f.close()"' % |
| 197 | (self.pyexe, fn), **kws) |
| 198 | assert_(s != 0) |
| 199 | assert_(o != '') |
| 200 | s, o = exec_command.exec_command( |
| 201 | '"%s" -c "f = open(\'%s\', \'r\'); print(f.read()); ' |
| 202 | 'f.close()"' % (self.pyexe, fn), execute_in=tmpdir, **kws) |
| 203 | assert_(s == 0) |
| 204 | assert_(o == 'Hello') |
| 205 | |
| 206 | def test_basic(self): |
| 207 | with redirect_stdout(StringIO()): |