Permalink
Browse files

Move directory creation into configure and correct path

  • Loading branch information...
dcramer committed Mar 27, 2012
1 parent be43f2c commit 887da4878a3c29724758b43d5f6bc941b46f6dc2
Showing with 18 additions and 13 deletions.
  1. +18 −13 nose_json/plugin.py
View
@@ -43,25 +43,30 @@ def options(self, parser, env):
def configure(self, options, config):
Plugin.configure(self, options, config)
self.config = config
- if self.enabled:
- self.stats = {'errors': 0,
- 'failures': 0,
- 'passes': 0,
- 'skipped': 0
- }
- self.results = []
- self.report_file = codecs.open(options.json_file, 'w',
- self.encoding, 'replace')
+ if not self.enabled:
+ return
+
+ self.stats = {'errors': 0,
+ 'failures': 0,
+ 'passes': 0,
+ 'skipped': 0
+ }
+ self.results = []
+
+ report_output = options.json_file
+
+ path = os.path.dirname(report_output)
+ if not os.path.exists(path):
+ os.makedirs(path)
+
+ self.report_file = codecs.open(report_output, 'w',
+ self.encoding, 'replace')
def report(self, stream):
self.stats['encoding'] = self.encoding
self.stats['total'] = (self.stats['errors'] + self.stats['failures']
+ self.stats['passes'] + self.stats['skipped'])
- path = os.path.dirname(self.report_file)
- if not os.path.exists(path):
- os.makedirs(path)
-
self.report_file.write(simplejson.dumps({
'stats': self.stats,
'results': self.results,

0 comments on commit 887da48

Please sign in to comment.