title: Can I use the Nose Xunit class directly to output Junit XML?
body: <p>We have a bunch of system tests that I'd like to integrate into Jenkins. As a result I thought I might try and be clever and use Nose's Xunit plugin to generate results files. My code looks like this:</p>
  
  <pre><code>
  from optparse import OptionParser
  from subprocess import call
  
  from nose.plugins.xunit import Xunit as xunit
  from nose.config import Config
  
  if __name__ == "__main__":
      p = OptionParser(usage="A simple wrapper for creating JUnit XML")
      p.add_option("-v", "--verbose",
                   action="store_true", dest="verbose", default=False,
                   help="generate extra information")
  
      # hook in xunit plugin options
      x = xunit()
      x.add_options(p)
  
      (options, args) = p.parse_args()
      x.configure(options, Config())
      for test in args:
          test_args = test.split(" ")
          test_name = test_args[0]
          if options.verbose: print "running: %s" % (test_name)
  
          x.startTest(test_name)
          result = call(test_args, shell=True)
          if result == 0:
              x.addSuccess(test_name)
          else:
              x.addFailure(test_name, None)
  
      x.report()
  </code></pre>
  
  <p>However when I run I get a failure:</p>
  
  <pre>
  17:24 ajb@sloy/x86_64 [perf_test.git] >./junitify.py -v "/bin/true" "/bin/false"
  running: /bin/true
  Traceback (most recent call last):
    File "./junitify.py", line 39, in 
      x.addSuccess(test_name)
    File "/usr/lib/python2.7/dist-packages/nose/plugins/xunit.py", line 239, in addSuccess
      self.stats['passes'] += 1
  AttributeError: 'Xunit' object has no attribute 'stats'
  </pre>
  
  <p>Which from looking at the code for xunit is because self.enabled was not set. However it's not entirely clear if it's possible to use the Xunit library in this way. Is what I'm trying to do possible? Is this just mis-understanding how this library should be initialised? Should I just use a different python library for generating the output?</p>
  
  <p>It would be a shame as we do use nose for running the doctest unit tests on a chunk of our python code under Jenkins.</p>