[Checkins] SVN: Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py Fix test failures on Windows.

Chris Withers chris at simplistix.co.uk
Mon May 1 08:06:19 EDT 2006


Log message for revision 67792:
  Fix test failures on Windows.

Changed:
  U   Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py

-=-
Modified: Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py
===================================================================
--- Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py	2006-05-01 12:05:40 UTC (rev 67791)
+++ Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py	2006-05-01 12:06:18 UTC (rev 67792)
@@ -11,6 +11,7 @@
 #
 ##############################################################################
 import unittest
+import os
 import tempfile
 import transaction
 from StringIO import StringIO
@@ -68,16 +69,20 @@
         transaction.savepoint(optimistic=True) # need an OID!
         oid = dm._p_oid
 
-        ostream = tempfile.NamedTemporaryFile(suffix='.xml')
+        handle, path = tempfile.mkstemp(suffix='.xml')
         try:
+            ostream = os.fdopen(handle,'wb')
             data = exportXML(connection, oid, ostream)
-            ostream.flush()
-            newobj = importXML(connection, ostream.name)
+            ostream.close()
+            newobj = importXML(connection, path)
+            self.failUnless(isinstance(newobj, DTMLMethod))
+            self.assertEqual(newobj.read(), dm.read())
         finally:
-            ostream.close()
+            # if this operaiton fails with a 'Permission Denied' error,
+            # then comment it out as it's probably masking a failure in
+            # the block above.
+            os.remove(path)
 
-        self.failUnless(isinstance(newobj, DTMLMethod))
-        self.assertEqual(newobj.read(), dm.read())
 
     def test_OFS_ObjectManager__importObjectFromFile_xml(self):
         from OFS.DTMLMethod import DTMLMethod
@@ -95,13 +100,17 @@
         oid = dm._p_oid
         sub = app._getOb('sub')
 
-        ostream = tempfile.NamedTemporaryFile(suffix='.xml')
+        handle, path = tempfile.mkstemp(suffix='.xml')
         try:
+            ostream = os.fdopen(handle,'wb')
             data = exportXML(connection, oid, ostream)
-            ostream.flush()
-            sub._importObjectFromFile(ostream.name, 0, 0)
+            ostream.close()
+            sub._importObjectFromFile(path, 0, 0)
         finally:
-            ostream.close()
+            # if this operaiton fails with a 'Permission Denied' error,
+            # then comment it out as it's probably masking a failure in
+            # the block above.
+            os.remove(path)
 
 def test_suite():
     return unittest.TestSuite((



More information about the Checkins mailing list