summaryrefslogtreecommitdiff
path: root/Lib/test/test_float.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-10-31 00:08:27 +0000
committerBrian Curtin <brian.curtin@gmail.com>2010-10-31 00:08:27 +0000
commitee139688d3d70ae8af00072cb8f0fb1d0d80a688 (patch)
tree0635866b5ba761c73dbded11ba7ef3d6d23dd11c /Lib/test/test_float.py
parentf62ae822d4badf3511cf7e6e9ecace6a7df2cddc (diff)
downloadcpython-git-ee139688d3d70ae8af00072cb8f0fb1d0d80a688.tar.gz
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. ........
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r--Lib/test/test_float.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 0328d1adc1..de5ca46fdf 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -540,19 +540,20 @@ class IEEEFormatTestCase(unittest.TestCase):
@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')