[Python-checkins] r86005 - in python/branches/release27-maint: Lib/test/test_float.py
brian.curtin
python-checkins at python.org
Sun Oct 31 02:08:27 CEST 2010
Author: brian.curtin
Date: Sun Oct 31 02:08:27 2010
New Revision: 86005
Log:
Merged revisions 86003 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86003 | brian.curtin | 2010-10-30 19:03:45 -0500 (Sat, 30 Oct 2010) | 2 lines
Fix ResourceWarning. Use context manager to properly close file.
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Lib/test/test_float.py
Modified: python/branches/release27-maint/Lib/test/test_float.py
==============================================================================
--- python/branches/release27-maint/Lib/test/test_float.py (original)
+++ python/branches/release27-maint/Lib/test/test_float.py Sun Oct 31 02:08:27 2010
@@ -540,19 +540,20 @@
@requires_IEEE_754
def test_format_testfile(self):
- for line in open(format_testfile):
- if line.startswith('--'):
- continue
- line = line.strip()
- if not line:
- continue
-
- lhs, rhs = map(str.strip, line.split('->'))
- fmt, arg = lhs.split()
- arg = float(arg)
- self.assertEqual(fmt % arg, rhs)
- if not math.isnan(arg) and copysign(1.0, arg) > 0.0:
- self.assertEqual(fmt % -arg, '-' + rhs)
+ with open(format_testfile) as testfile:
+ for line in open(format_testfile):
+ if line.startswith('--'):
+ continue
+ line = line.strip()
+ if not line:
+ continue
+
+ lhs, rhs = map(str.strip, line.split('->'))
+ fmt, arg = lhs.split()
+ arg = float(arg)
+ self.assertEqual(fmt % arg, rhs)
+ if not math.isnan(arg) and copysign(1.0, arg) > 0.0:
+ self.assertEqual(fmt % -arg, '-' + rhs)
def test_issue5864(self):
self.assertEquals(format(123.456, '.4'), '123.5')
More information about the Python-checkins
mailing list