Files
pytest2/py/io/testing/test_dupfile.py
hpk abc8cf09aa [svn r57321] merging the event branch:
* moving in test, misc, code, io directories and
  py/__init__.py
* py/bin/_find.py does not print to stderr anymore
* a few fixes to conftest files in other dirs
some more fixes and adjustments pending

--HG--
branch : trunk
2008-08-16 17:26:59 +02:00

21 lines
466 B
Python

import py
def test_dupfile():
somefile = py.std.os.tmpfile()
flist = []
for i in range(5):
nf = py.io.dupfile(somefile)
assert nf != somefile
assert nf.fileno() != somefile.fileno()
assert nf not in flist
print >>nf, i,
flist.append(nf)
for i in range(5):
f = flist[i]
f.close()
somefile.seek(0)
s = somefile.read()
assert s.startswith("01234")
somefile.close()