summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_file.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-02-14 17:41:18 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-02-14 17:41:18 (GMT)
commitcffcfed1263a255386c0da50709d6abc18accaab (patch)
treebe46b1becfc45183e734475095b3301e8a555bac /Lib/test/test_file.py
parent967aa8b3496df29f03895b5e30a590d77d337167 (diff)
downloadcpython-cffcfed1263a255386c0da50709d6abc18accaab.zip
cpython-cffcfed1263a255386c0da50709d6abc18accaab.tar.gz
cpython-cffcfed1263a255386c0da50709d6abc18accaab.tar.bz2
New test code failed to close the file. This caused
test_file to fail on Windows in reality (can't delete a still-open file), but a new bare "except:" hid that test_file failed on Windows, and leaving behind the still-open TESTFN caused a cascade of bogus failures in later tests. So, close the file, and stop hiding failure to unlink.
Diffstat (limited to 'Lib/test/test_file.py')
-rw-r--r--Lib/test/test_file.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index 69501df..efb06f4 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -323,18 +323,17 @@ try:
"failed. Got %r, expected %r" % (line, testline))
# Reading after iteration hit EOF shouldn't hurt either
f = open(TESTFN)
- for line in f:
- pass
try:
- f.readline()
- f.readinto(buf)
- f.read()
- f.readlines()
- except ValueError:
- raise TestFailed("read* failed after next() consumed file")
+ for line in f:
+ pass
+ try:
+ f.readline()
+ f.readinto(buf)
+ f.read()
+ f.readlines()
+ except ValueError:
+ raise TestFailed("read* failed after next() consumed file")
+ finally:
+ f.close()
finally:
- # Bare 'except' so as not to mask errors in the test
- try:
- os.unlink(TESTFN)
- except:
- pass
+ os.unlink(TESTFN)