[Jython-checkins] jython: Fix test failure (file not closed) in test_file_jy.
jeff.allen
jython-checkins at python.org
Sun Dec 11 02:59:53 EST 2016
https://hg.python.org/jython/rev/82a743a2455e
changeset: 7981:82a743a2455e
user: Jeff Allen <ja.py at farowl.co.uk>
date: Sat Dec 10 19:32:20 2016 +0000
summary:
Fix test failure (file not closed) in test_file_jy.
f.close() was missing from test_read_empty_file, but a with statement
is better anyway. And if here why not in test_issue2081 too?
files:
Lib/test/test_file_jy.py | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Lib/test/test_file_jy.py b/Lib/test/test_file_jy.py
--- a/Lib/test/test_file_jy.py
+++ b/Lib/test/test_file_jy.py
@@ -45,18 +45,18 @@
@unittest.skipUnless(hasattr(os, 'chmod'), 'chmod() support required for this test')
def test_issue2081(self):
- f = open(test_support.TESTFN, 'wb')
- f.close()
+ with open(test_support.TESTFN, 'wb'):
+ pass
os.chmod(test_support.TESTFN, 200) # write-only
- f = open(test_support.TESTFN, 'w') # should succeed, raised IOError (permission denied) prior to fix
- f.close()
+ with open(test_support.TESTFN, 'w'): # should succeed, raised IOError (permission denied) prior to fix
+ pass
# http://bugs.jython.org/issue2358
def test_read_empty_file(self):
- f = open(test_support.TESTFN, 'w')
- f.close()
- f = open(test_support.TESTFN)
- self.assertEqual(f.read(), '')
+ with open(test_support.TESTFN, 'w'):
+ pass
+ with open(test_support.TESTFN) as f:
+ self.assertEqual(f.read(), '')
# http://bugs.jython.org/issue2358
@unittest.skipUnless(System.getProperty('os.name') == u'Linux', 'Linux required')
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list