[Python-checkins] python/dist/src/Lib/test test_pkg.py,1.16,1.17
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Tue, 13 Aug 2002 18:05:59 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv18298/python/Lib/test
Modified Files:
test_pkg.py
Log Message:
runtest(): I don't know why we don't just use TESTFN, but if we have to
do bizarre things to get a temp file, I changed it to use mkstemp instead
of NamedTemporaryFile. This tried to leave the file open while passing
its name to execfile(). On Win2K (but not Win9X), though, a file created
with O_TEMPORARY cannot be opened again, so the test failed with a
permission error when execfile tried to open it. Closer to the truth:
a file created with O_TEMPORARY can be opened again, but only if the
file is also created with SHARE_DELETE access via the Win32 CreateFile()
function. There's no way to get at that from MS's version of libc, though
(we'd have to ditch the "std" C file functions in favor of Win32 API
calls).
Index: test_pkg.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pkg.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** test_pkg.py 9 Aug 2002 16:37:35 -0000 1.16
--- test_pkg.py 14 Aug 2002 01:05:57 -0000 1.17
***************
*** 57,72 ****
mkhier(root, hier)
savepath = sys.path[:]
! codefile = tempfile.NamedTemporaryFile()
! codefile.write(code)
! codefile.flush()
try:
sys.path.insert(0, root)
if verbose: print "sys.path =", sys.path
try:
! execfile(codefile.name, globals(), {})
except:
traceback.print_exc(file=sys.stdout)
finally:
sys.path[:] = savepath
try:
cleanout(root)
--- 57,73 ----
mkhier(root, hier)
savepath = sys.path[:]
! fd, fname = tempfile.mkstemp(binary=False)
! os.write(fd, code)
! os.close(fd)
try:
sys.path.insert(0, root)
if verbose: print "sys.path =", sys.path
try:
! execfile(fname, globals(), {})
except:
traceback.print_exc(file=sys.stdout)
finally:
sys.path[:] = savepath
+ os.unlink(fname)
try:
cleanout(root)