Commit 076623bf authored by Brian Curtin's avatar Brian Curtin

Fix ResourceWarning. Use context manager to properly close file.

parent 3ddcaafb
...@@ -540,17 +540,18 @@ class FormatTestCase(unittest.TestCase): ...@@ -540,17 +540,18 @@ class FormatTestCase(unittest.TestCase):
@requires_IEEE_754 @requires_IEEE_754
def test_format_testfile(self): def test_format_testfile(self):
for line in open(format_testfile): with open(format_testfile) as testfile:
if line.startswith('--'): for line in testfile:
continue if line.startswith('--'):
line = line.strip() continue
if not line: line = line.strip()
continue if not line:
continue
lhs, rhs = map(str.strip, line.split('->'))
fmt, arg = lhs.split() lhs, rhs = map(str.strip, line.split('->'))
self.assertEqual(fmt % float(arg), rhs) fmt, arg = lhs.split()
self.assertEqual(fmt % -float(arg), '-' + rhs) self.assertEqual(fmt % float(arg), rhs)
self.assertEqual(fmt % -float(arg), '-' + rhs)
def test_issue5864(self): def test_issue5864(self):
self.assertEquals(format(123.456, '.4'), '123.5') self.assertEquals(format(123.456, '.4'), '123.5')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment