def testRWfile(self): tmp_file = processes._Tmp() tmp_file.write('Hello World') src = processes._Tmp() src.write('123') src.seek(0) tmp_file.seek(0) tmp_file.truncate(0) pipe_through_command('cat', src, tmp_file) tmp_file.seek(0) assert tmp_file.read() == '123'
def testDelTmp(self): tmp_file = processes._Tmp() name = tmp_file.name assert os.path.exists(name) tmp_file = None gc.collect() assert not os.path.exists(name)
def testWriteFileno(self): tmp_file = processes._Tmp() tmp_file.seek(0) tmp_file.truncate(0) pipe_through_command('echo Foo', None, tmp_file) tmp_file.seek(0) assert tmp_file.read() == 'Foo\n'
def testStringIO(self): a = StringIO() pipe_through_command('echo Hello', None, a) tmp_file = processes._Tmp() tmp_file.write('Hello World') tmp_file.seek(1) pipe_through_command('cat', tmp_file, a) assert a.getvalue() == 'Hello\nHello World'
def testTmp(self): tmp_file = processes._Tmp() tmp_file.write('Hello') print >>tmp_file, ' ', tmp_file.flush() os.write(tmp_file.fileno(), 'World') tmp_file.seek(0) assert tmp_file.read() == 'Hello World'
def testTmp(self): tmp_file = processes._Tmp() tmp_file.write('Hello') print >> tmp_file, ' ', tmp_file.flush() os.write(tmp_file.fileno(), 'World') tmp_file.seek(0) assert tmp_file.read() == 'Hello World'