[pypy-commit] pypy win32-stdlib: clean up cruft, fix parts of test_mailbox

mattip noreply at buildbot.pypy.org
Wed Apr 11 13:24:31 CEST 2012


Author: Matti Picus <matti.picus at gmail.com>
Branch: win32-stdlib
Changeset: r54285:870298de090f
Date: 2012-04-11 14:23 +0300
http://bitbucket.org/pypy/pypy/changeset/870298de090f/

Log:	clean up cruft, fix parts of test_mailbox

diff --git a/lib-python/2.7/test/test_mailbox.py b/lib-python/modified-2.7/test/test_mailbox.py
rename from lib-python/2.7/test/test_mailbox.py
rename to lib-python/modified-2.7/test/test_mailbox.py
--- a/lib-python/2.7/test/test_mailbox.py
+++ b/lib-python/modified-2.7/test/test_mailbox.py
@@ -44,7 +44,7 @@
                 for name in dirs:
                     os.rmdir(os.path.join(path, name))
             os.rmdir(target)
-        elif os.path.exists(target):
+        elif os.pathtexists(target):
             os.remove(target)
 
 
@@ -137,6 +137,7 @@
         msg = self._box.get(key1)
         self.assertEqual(msg['from'], 'foo')
         self.assertEqual(msg.fp.read(), '1')
+        msg.fp.close()
 
     def test_getitem(self):
         # Retrieve message using __getitem__()
@@ -169,10 +170,12 @@
         # Get file representations of messages
         key0 = self._box.add(self._template % 0)
         key1 = self._box.add(_sample_message)
-        self.assertEqual(self._box.get_file(key0).read().replace(os.linesep, '\n'),
-                         self._template % 0)
-        self.assertEqual(self._box.get_file(key1).read().replace(os.linesep, '\n'),
-                         _sample_message)
+        msg = self._box.get_file(key0)
+        self.assertEqual(msg.read().replace(os.linesep, '\n'), self._template % 0)
+        msg.close()
+        msg = self._box.get_file(key1)
+        self.assertEqual(msg.read().replace(os.linesep, '\n'), _sample_message)
+        msg.close()
 
     def test_iterkeys(self):
         # Get keys using iterkeys()
diff --git a/lib-python/modified-2.7/test/test_old_mailbox.py b/lib-python/modified-2.7/test/test_old_mailbox.py
--- a/lib-python/modified-2.7/test/test_old_mailbox.py
+++ b/lib-python/modified-2.7/test/test_old_mailbox.py
@@ -7,15 +7,6 @@
 import unittest
 from test import test_support
 
-def myunlink(path):
-    try:
-        os._unlink(path)
-    except:
-        import pdb;pdb.set_trace()
-
-#os._unlink = os.unlink
-#os.unlink = myunlink
-
 # cleanup earlier tests
 try:
     os.unlink(test_support.TESTFN)
@@ -44,14 +35,11 @@
         self._msgfiles = []
 
     def tearDown(self):
-        try:  
-            map(os.unlink, self._msgfiles)
-            os.rmdir(os.path.join(self._dir, "cur"))
-            os.rmdir(os.path.join(self._dir, "tmp"))
-            os.rmdir(os.path.join(self._dir, "new"))
-            os.rmdir(self._dir)
-        except:
-            import pdb;pdb.set_trace()
+        map(os.unlink, self._msgfiles)
+        os.rmdir(os.path.join(self._dir, "cur"))
+        os.rmdir(os.path.join(self._dir, "tmp"))
+        os.rmdir(os.path.join(self._dir, "new"))
+        os.rmdir(self._dir)
 
     def createMessage(self, dir, mbox=False):
         t = int(time.time() % 1000000)


More information about the pypy-commit mailing list