summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenzo Lucioni <renzo@renzolucioni.com>2015-01-26 13:50:12 -0500
committerJohn Szakmeister <john@szakmeister.net>2015-11-28 04:58:29 -0500
commit53ca70f5ccd41ed8ced343728c784363f0f8c818 (patch)
tree423ea98771eecc4f3289c4f77878715af6d78595
parentad63d9a357d07c74b4cdcc4da32c7a02e03a57a6 (diff)
downloadnose-53ca70f5ccd41ed8ced343728c784363f0f8c818.tar.gz
Close idfile object in a finally clause
-rw-r--r--nose/plugins/testid.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/nose/plugins/testid.py b/nose/plugins/testid.py
index ae8119b..0f94c87 100644
--- a/nose/plugins/testid.py
+++ b/nose/plugins/testid.py
@@ -176,8 +176,8 @@ class TestId(Plugin):
test addresses, if they are found in my dict of tests.
"""
log.debug('ltfn %s %s', names, module)
+ fh = open(self.idfile, 'rb')
try:
- fh = open(self.idfile, 'rb')
data = load(fh)
if 'ids' in data:
self.ids = data['ids']
@@ -197,7 +197,6 @@ class TestId(Plugin):
'Loaded test ids %s tests %s failed %s sources %s from %s',
self.ids, self.tests, self.failed, self.source_names,
self.idfile)
- fh.close()
except ValueError, e:
# load() may throw a ValueError when reading the ids file, if it
# was generated with a newer version of Python than we are currently
@@ -205,6 +204,8 @@ class TestId(Plugin):
log.debug('Error loading %s : %s', self.idfile, str(e))
except IOError:
log.debug('IO error reading %s', self.idfile)
+ finally:
+ fh.close()
if self.loopOnFailed and self.failed:
self.collecting = False