Browse files

Delay opening file pointers until reporting

  • Loading branch information...
1 parent 887da48 commit d4137f315bb173fe39335c989236e4ac991bb762 @dcramer committed Jun 4, 2012
Showing with 7 additions and 8 deletions.
  1. +6 −7 nose_json/plugin.py
  2. +1 −1 setup.py
View
13 nose_json/plugin.py
@@ -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()
View
2 setup.py
@@ -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.',

0 comments on commit d4137f3

Please sign in to comment.