Skip to content

Commit

Permalink
testid: don't traceback if the idfile doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
jszakmeister committed Nov 28, 2015
1 parent 53ca70f commit 16df8f4
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions nose/plugins/testid.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,36 +176,37 @@ def loadTestsFromNames(self, names, module=None):
test addresses, if they are found in my dict of tests.
"""
log.debug('ltfn %s %s', names, module)
fh = open(self.idfile, 'rb')
try:
data = load(fh)
if 'ids' in data:
self.ids = data['ids']
self.failed = data['failed']
self.source_names = data['source_names']
else:
# old ids field
self.ids = data
self.failed = []
self.source_names = names
if self.ids:
self.id = max(self.ids) + 1
self.tests = dict(list(zip(list(self.ids.values()), list(self.ids.keys()))))
else:
self.id = 1
log.debug(
'Loaded test ids %s tests %s failed %s sources %s from %s',
self.ids, self.tests, self.failed, self.source_names,
self.idfile)
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
# running.
log.debug('Error loading %s : %s', self.idfile, str(e))
fh = open(self.idfile, 'rb')
try:
data = load(fh)
if 'ids' in data:
self.ids = data['ids']
self.failed = data['failed']
self.source_names = data['source_names']
else:
# old ids field
self.ids = data
self.failed = []
self.source_names = names
if self.ids:
self.id = max(self.ids) + 1
self.tests = dict(list(zip(list(self.ids.values()), list(self.ids.keys()))))
else:
self.id = 1
log.debug(
'Loaded test ids %s tests %s failed %s sources %s from %s',
self.ids, self.tests, self.failed, self.source_names,
self.idfile)
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
# running.
log.debug('Error loading %s : %s', self.idfile, str(e))
finally:
fh.close()
except IOError:
log.debug('IO error reading %s', self.idfile)
finally:
fh.close()

if self.loopOnFailed and self.failed:
self.collecting = False
Expand Down

0 comments on commit 16df8f4

Please # to comment.