[Numpy-svn] r5252 - trunk/numpy/ma/tests

numpy-svn@scip... numpy-svn@scip...
Tue Jun 3 18:41:22 CDT 2008


Author: pierregm
Date: 2008-06-03 18:41:20 -0500 (Tue, 03 Jun 2008)
New Revision: 5252

Modified:
   trunk/numpy/ma/tests/test_mrecords.py
Log:
use tempfile.mkstemp for the creation of temporary files

Modified: trunk/numpy/ma/tests/test_mrecords.py
===================================================================
--- trunk/numpy/ma/tests/test_mrecords.py	2008-06-03 23:14:16 UTC (rev 5251)
+++ trunk/numpy/ma/tests/test_mrecords.py	2008-06-03 23:41:20 UTC (rev 5252)
@@ -375,12 +375,12 @@
 """
         import os
         from datetime import datetime
-        fname = 'tmp%s' % datetime.now().strftime("%y%m%d%H%M%S%s")
-        f = open(fname, 'w')
-        f.write(fcontent)
-        f.close()
-        mrectxt = fromtextfile(fname,delimitor=',',varnames='ABCDEFG')
-        os.remove(fname)
+        import tempfile
+        (tmp_fd,tmp_fl) = tempfile.mkstemp()
+        os.write(tmp_fd, fcontent)
+        os.close(tmp_fd)
+        mrectxt = fromtextfile(tmp_fl, delimitor=',',varnames='ABCDEFG')
+        os.remove(tmp_fl)
         #
         assert(isinstance(mrectxt, MaskedRecords))
         assert_equal(mrectxt.F, [1,1,1,1])



More information about the Numpy-svn mailing list