Skip to content

Commit

Permalink
Delay opening file pointers until reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Jun 4, 2012
1 parent 887da48 commit d4137f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions nose_json/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,18 @@ def configure(self, options, config):
if not os.path.exists(path):
os.makedirs(path)

self.report_file = codecs.open(report_output, 'w',
self.encoding, 'replace')
self.report_output = report_output

def report(self, stream):
self.stats['encoding'] = self.encoding
self.stats['total'] = (self.stats['errors'] + self.stats['failures']
+ self.stats['passes'] + self.stats['skipped'])

self.report_file.write(simplejson.dumps({
'stats': self.stats,
'results': self.results,
}))
self.report_file.close()
with codecs.open(self.report_output, 'w', self.encoding, 'replace') as fp:
fp.write(simplejson.dumps({
'stats': self.stats,
'results': self.results,
}))

def startTest(self, test):
self._timer = time()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='nose-json',
version='0.2.3',
version='0.2.4',
author='David Cramer',
author_email='dcramer@gmail.com',
description='A JSON report plugin for Nose.',
Expand Down

0 comments on commit d4137f3

Please sign in to comment.