title: Is there a way to make py.test ignore SystemExit raised on a child process?
body: <p>I'm testing a Python module which contains the following snippet of code.</p>
  
  <pre><code>        r, w = os.pipe()
          pid = os.fork()
          if pid:
              os.close(w)        # use os.close() to close a file descriptor
              r = os.fdopen(r)   # turn r into a file object
              # read serialized object from ``r`` and persists onto storage medium
              self.ofs.put_stream(bucket, label, r, metadata)
              os.waitpid(pid, 0) # make sure the child process gets cleaned up
          else:
              os.close(r)
              w = os.fdopen(w, 'w')
              # serialize object onto ``w``
              pickle.dump(obj, w)
              w.close()
              sys.exit(0)
          return result
  </code></pre>
  
  <p>All tests pass, but there's s <em>difficulty</em> in regards to <code>sys.exit(0)</code>.
  When <code>sys.exit(0)</code> executes, it raises <code>SystemExit</code>, which is intercepted by <code>py.test</code> and reported as an error in the console.</p>
  
  <p>I don't understand in detail what <code>py.test</code> does internally, but looks like it goes ahead and ends up ignoring such event raised by the child process. In the end, all tests pass, which is good.</p>
  
  <p>But I'd like to have a clean output in the console.</p>
  
  <p>Is there a way to make <code>py.test</code> produce a clean output?</p>
  
  <p>For your information:</p>
  
  <ul>
  <li>Debian Jessie, kernel 3.12.6</li>
  <li>Python 2.7.6</li>
  <li>pytest 2.5.2</li>
  </ul>
  
  <p>Thanks :)</p>