diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-10-31 00:05:24 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-10-31 00:05:24 (GMT) |
commit | a813a638ef92dfde2cff66339b319780691f4bb3 (patch) | |
tree | bfe8ab59aa33004d54f3694c1cd47b05348e2b90 /Lib | |
parent | 46805e9102c50c67d760d97cabab4daf1f4f5b13 (diff) | |
download | cpython-a813a638ef92dfde2cff66339b319780691f4bb3.zip cpython-a813a638ef92dfde2cff66339b319780691f4bb3.tar.gz cpython-a813a638ef92dfde2cff66339b319780691f4bb3.tar.bz2 |
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')
-rw-r--r-- | Lib/test/test_float.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index fa6fde3..bdaf082 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -401,17 +401,18 @@ class FormatTestCase(unittest.TestCase): @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"), "test requires IEEE 754 doubles") 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() - self.assertEqual(fmt % float(arg), rhs) - self.assertEqual(fmt % -float(arg), '-' + rhs) + with open(format_testfile) as testfile: + for line in testfile: + if line.startswith('--'): + continue + line = line.strip() + if not line: + continue + + lhs, rhs = map(str.strip, line.split('->')) + fmt, arg = lhs.split() + self.assertEqual(fmt % float(arg), rhs) + self.assertEqual(fmt % -float(arg), '-' + rhs) def test_issue5864(self): self.assertEquals(format(123.456, '.4'), '123.5') |