summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-10-14 22:11:44 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-10-14 22:11:44 (GMT)
commit92f60ed82a302035009835a8d63ff714118a96ad (patch)
treea119000028c02ecf0317859d0bcda37fe4c505b4 /Lib/test/test_decimal.py
parent73315e92009c88acf53e497a0b9fcd93cd735aed (diff)
downloadcpython-92f60ed82a302035009835a8d63ff714118a96ad.zip
cpython-92f60ed82a302035009835a8d63ff714118a96ad.tar.gz
cpython-92f60ed82a302035009835a8d63ff714118a96ad.tar.bz2
More proper closing of files
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 4a35465..a88da5b 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -225,14 +225,15 @@ class DecimalTest(unittest.TestCase):
if skip_expected:
raise unittest.SkipTest
return
- for line in open(file):
- line = line.replace('\r\n', '').replace('\n', '')
- #print line
- try:
- t = self.eval_line(line)
- except DecimalException as exception:
- #Exception raised where there shoudn't have been one.
- self.fail('Exception "'+exception.__class__.__name__ + '" raised on line '+line)
+ with open(file) as f:
+ for line in f:
+ line = line.replace('\r\n', '').replace('\n', '')
+ #print line
+ try:
+ t = self.eval_line(line)
+ except DecimalException as exception:
+ #Exception raised where there shoudn't have been one.
+ self.fail('Exception "'+exception.__class__.__name__ + '" raised on line '+line)
return