[pypy-svn] r64318 - in pypy/trunk/lib-python: . modified-2.5.2/test

afa at codespeak.net afa at codespeak.net
Sat Apr 18 00:43:20 CEST 2009


Author: afa
Date: Sat Apr 18 00:43:17 2009
New Revision: 64318

Added:
   pypy/trunk/lib-python/modified-2.5.2/test/test_old_mailbox.py
      - copied, changed from r64314, pypy/trunk/lib-python/2.5.2/test/test_old_mailbox.py
Modified:
   pypy/trunk/lib-python/win32-failures.txt
Log:
Fix most of test_old_mailbox by explicitely closing all opened files

The remaining failure is probably a seek/tell mismatch.
(test passes if file is opened in binary mode)


Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_old_mailbox.py (from r64314, pypy/trunk/lib-python/2.5.2/test/test_old_mailbox.py)
==============================================================================
--- pypy/trunk/lib-python/2.5.2/test/test_old_mailbox.py	(original)
+++ pypy/trunk/lib-python/modified-2.5.2/test/test_old_mailbox.py	Sat Apr 18 00:43:17 2009
@@ -63,51 +63,61 @@
         self._msgfiles.append(newname)
         return tmpname
 
+    def mbox_has_next(self):
+        m = self.mbox.next()
+        if m:
+            m.fp.close()
+            return True
+        else:
+            return False
+
     def test_empty_maildir(self):
         """Test an empty maildir mailbox"""
         # Test for regression on bug #117490:
         self.mbox = mailbox.Maildir(test_support.TESTFN)
         self.assert_(len(self.mbox) == 0)
-        self.assert_(self.mbox.next() is None)
-        self.assert_(self.mbox.next() is None)
+        self.assert_(not self.mbox_has_next())
+        self.assert_(not self.mbox_has_next())
 
     def test_nonempty_maildir_cur(self):
         self.createMessage("cur")
         self.mbox = mailbox.Maildir(test_support.TESTFN)
         self.assert_(len(self.mbox) == 1)
-        self.assert_(self.mbox.next() is not None)
-        self.assert_(self.mbox.next() is None)
-        self.assert_(self.mbox.next() is None)
+        self.assert_(self.mbox_has_next())
+        self.assert_(not self.mbox_has_next())
+        self.assert_(not self.mbox_has_next())
 
     def test_nonempty_maildir_new(self):
         self.createMessage("new")
         self.mbox = mailbox.Maildir(test_support.TESTFN)
         self.assert_(len(self.mbox) == 1)
-        self.assert_(self.mbox.next() is not None)
-        self.assert_(self.mbox.next() is None)
-        self.assert_(self.mbox.next() is None)
+        self.assert_(self.mbox_has_next())
+        self.assert_(not self.mbox_has_next())
+        self.assert_(not self.mbox_has_next())
 
     def test_nonempty_maildir_both(self):
         self.createMessage("cur")
         self.createMessage("new")
         self.mbox = mailbox.Maildir(test_support.TESTFN)
         self.assert_(len(self.mbox) == 2)
-        self.assert_(self.mbox.next() is not None)
-        self.assert_(self.mbox.next() is not None)
-        self.assert_(self.mbox.next() is None)
-        self.assert_(self.mbox.next() is None)
+        self.assert_(self.mbox_has_next())
+        self.assert_(self.mbox_has_next())
+        self.assert_(not self.mbox_has_next())
+        self.assert_(not self.mbox_has_next())
 
     def test_unix_mbox(self):
         ### should be better!
         import email.Parser
         fname = self.createMessage("cur", True)
+        fp = open(fname)
         n = 0
-        for msg in mailbox.PortableUnixMailbox(open(fname),
+        for msg in mailbox.PortableUnixMailbox(fp,
                                                email.Parser.Parser().parse):
             n += 1
             self.assertEqual(msg["subject"], "Simple Test")
             self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
         self.assertEqual(n, 1)
+        fp.close()
 
 class MboxTestCase(unittest.TestCase):
     def setUp(self):
@@ -138,9 +148,13 @@
 body4
 """)
         f.close()
-        box = mailbox.UnixMailbox(open(self._path, 'r'))
-        self.assert_(len(list(iter(box))) == 4)
 
+        f = open(self._path, 'r')
+        try:
+            box = mailbox.UnixMailbox(f)
+            self.assertEquals(len(list(iter(box))), 4)
+        finally:
+            f.close()
 
     # XXX We still need more tests!
 

Modified: pypy/trunk/lib-python/win32-failures.txt
==============================================================================
--- pypy/trunk/lib-python/win32-failures.txt	(original)
+++ pypy/trunk/lib-python/win32-failures.txt	Sat Apr 18 00:43:17 2009
@@ -9,13 +9,15 @@
 test_locale
 test_mmap
 test_netrc
-test_old_mailbox
+test_old_mailbox    [unlink failures corrected]
+                    - test_from_regex fails probably because of seek() and tell() issues
+                      (test passes if file is opened in binary mode)
 test_os             - test_1565150: rewrite utime() to use SetFileTime
-                    - test_access: ??
-test_popen2
+                    - test_access: this test seems flaky
+test_popen2         missing os.popen2
 test_random
 test_repr           [Done] probably
-test_runpy
+test_runpy          [Done]
 test_shutil         - when os.utime uses SetFileTime, raise WindowsError instead of OSError.
 test_site
 test_socket



More information about the Pypy-commit mailing list