From: <pj...@us...> - 2009-05-30 06:42:35
|
Revision: 6427 http://jython.svn.sourceforge.net/jython/?rev=6427&view=rev Author: pjenvey Date: 2009-05-30 06:41:33 +0000 (Sat, 30 May 2009) Log Message: ----------- o close some mailbox file handles o skip test_shutil.test_on_error which is questionable for Jython Modified Paths: -------------- trunk/jython/Lib/mailbox.py trunk/jython/Lib/test/test_old_mailbox.py trunk/jython/Lib/test/test_shutil.py Modified: trunk/jython/Lib/mailbox.py =================================================================== --- trunk/jython/Lib/mailbox.py 2009-05-30 06:40:55 UTC (rev 6426) +++ trunk/jython/Lib/mailbox.py 2009-05-30 06:41:33 UTC (rev 6427) @@ -955,6 +955,7 @@ if self._locked: _unlock_file(self._file) _sync_close(self._file) + self._file.close() del self._file self._locked = False @@ -1780,6 +1781,7 @@ def close(self): """Close the file.""" + self._file.close() del self._file def _read(self, size, read_method): Modified: trunk/jython/Lib/test/test_old_mailbox.py =================================================================== --- trunk/jython/Lib/test/test_old_mailbox.py 2009-05-30 06:40:55 UTC (rev 6426) +++ trunk/jython/Lib/test/test_old_mailbox.py 2009-05-30 06:41:33 UTC (rev 6427) @@ -1,6 +1,7 @@ # This set of tests exercises the backward-compatibility class # in mailbox.py (the ones without write support). +from __future__ import with_statement import mailbox import os import time @@ -63,6 +64,10 @@ self._msgfiles.append(newname) return tmpname + def assert_and_close(self, message): + self.assert_(message is not None) + message.fp.close() + def test_empty_maildir(self): """Test an empty maildir mailbox""" # Test for regression on bug #117490: @@ -75,7 +80,7 @@ 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_and_close(self.mbox.next()) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None) @@ -83,7 +88,7 @@ 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_and_close(self.mbox.next()) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None) @@ -92,8 +97,8 @@ 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_and_close(self.mbox.next()) + self.assert_and_close(self.mbox.next()) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None) @@ -102,11 +107,12 @@ import email.Parser fname = self.createMessage("cur", True) n = 0 - for msg in mailbox.PortableUnixMailbox(open(fname), - email.Parser.Parser().parse): - n += 1 - self.assertEqual(msg["subject"], "Simple Test") - self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE)) + with open(fname) as fp: + 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) class MboxTestCase(unittest.TestCase): @@ -139,7 +145,10 @@ """) f.close() box = mailbox.UnixMailbox(open(self._path, 'r')) - self.assert_(len(list(iter(box))) == 4) + messages = list(iter(box)) + self.assert_(len(messages) == 4) + for message in messages: + message.fp.close() # XXX We still need more tests! Modified: trunk/jython/Lib/test/test_shutil.py =================================================================== --- trunk/jython/Lib/test/test_shutil.py 2009-05-30 06:40:55 UTC (rev 6426) +++ trunk/jython/Lib/test/test_shutil.py 2009-05-30 06:41:33 UTC (rev 6427) @@ -18,8 +18,11 @@ # See bug #1071513 for why we don't run this on cygwin # and bug #1076467 for why we don't run this as root. + # XXX: Fails on Jython because Java resets the S_IREAD permission + # when removing the file if (hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin' - and not (hasattr(os, 'geteuid') and os.geteuid() == 0)): + and not (hasattr(os, 'geteuid') and os.geteuid() == 0) + and (not test_support.is_jython or os._name != 'nt')): def test_on_error(self): self.errorState = 0 os.mkdir(TESTFN) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |